View Single Post
 
Old 07-27-2012, 06:52 AM
okiegirl okiegirl is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Jul 2012
Posts: 4
okiegirl is on a distinguished road
Cool Displaying pictures from a field with a file path

This is long but I am working with 3 different programs and I will be adding Excel to the mix soon, so here it goes. I have created a frontend Access 2010 database with an SQL backend (MySQL 2005) in an office environment stored on a server (Server 2003). My knowledge level isn't high on visual basic but I can do a lot of basic stuff and calculations. I have a hyperlink form field in Access where someone can go get a picture and it will display a thumbnail and in VB it renames the picture and saves it in a directory folder I created, then it stores the new file path in a text field (Photo1). All of the form data goes into a table that I use as my data source in Word. I need to have this picture go into a Word doc, all the merge fields which work great, except for this picture. It comes in and states "The linked image cannot be displayed. The file may have been moved, renamed, or deleted. Verify that the link points to the correct file and location." I have created various VB for this field and tweaked the field itself and nothing seems to work. Right now I have the field in a table and structured like this:

{INCLUDEPICTURE "{MERGEFIELD\"Photo1\"}.jpg" \d \*MERGEFORMAT }

I also tried adding just {MERGEFIELD Photo1 } and then putting VB in to run when the doc opened but it didn't work (See below).
Code:
Private Sub AssemblyMeeting_Open()
Dim Table As Table
Dim Cell As Cell
FileName = Cell.Range.Text
Dim FileName As String
Dim strCell As String
Set Table = ActiveDocument.Tables(1)
Set PicCell = ActiveDocument.Range(Start:=Table.Cell(1, 1).Range _
  .Start, End:=Table.Cell(1, 2).Range.End)
For Each Cell In Table.Range.Cells
  strCell = FileName
  If FileName = "" Then
    Cell.Value = ""
  Else
    With Cell.Range
      .Delete
      .InlineShapes.AddPicture FileName:=FileName, LinkToFile:=False, SaveWithDocument:=True
      .InlineShapes.AddPicture FileName:=PicCell, LinkToFile:=False, SaveWithDocument:=True
    End With
  End If
Next
End Sub
The file path will change everytime the Word document is generated so I can't just save a picture in it, I need it to reference the field that displays the file path. Any help would be great! Thank You!

Last edited by macropod; 07-28-2012 at 01:52 AM. Reason: Added Code Tags & Formatting
Reply With Quote