photo object link from database

B

Bruce Hensley

I have a folder with a collection of photos, and a database with the
filespecs of the photos, along with other characteristics about the
photos (like subject). I would like to create a drawing with selected
photos and their associated characteristics. Ideally, I would like to
be able to right-click a shape, choose "Select database record", pick
a photo record by name, and have both the characteristic data and the
photo updated on the drawing.

Using "Tools..Link to database", I have successfully created database
links to shapes so that the characteristics work as desired. I can
insert the photos as linked objects using Insert > Object > Create
from file - Link to file. However, I can't figure how to establish or
update the photo links based on the filespecs in the database.

Any help would be greatly appreciated.

Bruce Hensley

P.S. Platform -
Visio Standard 2002
MS Access 97
Win 2000
JPG images

P.P.S Please excuse the crosspost from ..developer.shapesheet
 
B

Bruce Hensley

I'm part way there, but still need help.

With the code below, I can drop my shape, be prompted for a matching
database record, and have the photo and database info presented in a
grouped shape.

What I still would like is the ability to change the link to a
different photo when I change the database record that the shape is
linked to. I envision something like ...

[I can guess how to do this]
- doubleclick event for shape
- uses RUNADDON to select new record
- get filespec as below
- ungroup shape

[this is where I get lost ... how do I know which shape to delete?]
- delete picture

[OK from here I think]
- insert new picture from file as before
- regroup

Again, any help would be appreciated.

Bruce Hensley
------------------
Working code ...

Private Sub AddPosition(ByVal Shape As IVShape)
'Run by CALLTHIS("AddPosition") in the EventDrop event for the shape

Dim shpPic As Visio.Shape 'shape to hold picture
Dim cellobj As Cell
Dim strPosNr As String
Dim strPhotoFile As String

Dim pagObj As Visio.Page
Set pagObj = Visio.ActiveDocument.Pages(1)

Dim slct As Selection
Set slct = Visio.ActiveWindow.Selection

Const FOLDER = "[path to photos]"

'Select the database record for the shape
'The cell User.Command1 contains RUNADDON("Database Select Record")
Set cellobj = Shape.Cells("User.Command1")
cellobj.Trigger

'Get the position number from database
strPosNr = Shape.Cells("prop.PosNr").Formula
strPosNr = Mid(strPosNr, 2, Len(strPosNr) - 2)

'Insert the picture object
Set shpPic = pagObj.InsertFromFile(FOLDER & strPosNr & ".jpg", 0)

'Size the picture
shpPic.Cells("width").Formula = "1.25 in."
shpPic.Cells("height").Formula = "1.25 in."

'Set top center of text box as pin location
Shape.Cells("LocPinX").Formula = "Width*0.5"
Shape.Cells("LocPinY").Formula = "Height"

'Set bottom center of picture as pin location
shpPic.Cells("LocPinX").Formula = "Width*0.5"
shpPic.Cells("LocPinY").Formula = "0"

'Pin the picture to the textbox
shpPic.Cells("PinX").Formula = Shape.Cells("PinX").Formula
shpPic.Cells("PinY").Formula = Shape.Cells("PinY").Formula

'Group the picture with the textbox
slct.Select shpPic, 2
slct.Select Shape, 2
slct.Group
slct.DeselectAll

'Set cellobj = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top