
Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
A user would open up a word templete (.dot) file. The form embedded into the
.dot file would prompt the user to fill out some fields, including one to
attach a jpg/gif/bmp into the form which would then be imported into the dot
file along with the answers to the other fields
Doug Robbins - Word MVP - 24 Feb 2006 19:11 GMT
For this you should be using a userform of the type discussed in the article
"How to create a Userform" at:
http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm
Then you need a button on the form with a caption something like "Browse for
Image" and for the Click() event for that form, you would use the following
code:
With Dialogs(wdDialogInsertPicture)
If .Display Then
'Populate the txtOrgChartPath control with the selected filename
txtOrgChartPath = WordBasic.FilenameInfo$(.Name, 1)
cmdInsertOrgChart.Enabled = True
End If
End With
In the form from which I grabbed this piece of code, the user was browsing
for a file that contained and organization chart and there was a textbox
(txtOrgChartPath) on the form that was populated with the path and filename
of the file that was selected by the user when the InsertPicture dialog was
displayed. The code also activated a button that when clicked, inserted the
organisation chart into the document using the following code:
Private Sub cmdInsertOrgChart_Click()
' Check that a file has been selected
If InStr(txtOrgChartPath, ":") = 0 Then
MsgBox "You must select a file for the Organization Chart."
Exit Sub
End If
'Insert organization chart into Quality Manual
Set myDoc = Documents.Open(PathofSystemFiles & "\Quality
Manual\Quality_Manual.doc")
If myDoc.Bookmarks.Exists("Org_Chart") = True Then
'Clear existing organization chart
myDoc.Bookmarks("Org_Chart").Range.Tables(1).Cell(1, 2).Range.Delete
'Insert new organization chart
myDoc.Bookmarks("Org_Chart").Range.Tables(1).Cell(1,
2).Range.InlineShapes.AddPicture Filename:=txtOrgChartPath
'Save and close the document
myDoc.Save
End If
myDoc.Close
End Sub
You will need to modify this for your situation, but it should show you the
necessary syntax to use.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
>A user would open up a word templete (.dot) file. The form embedded into
>the
> .dot file would prompt the user to fill out some fields, including one to
> attach a jpg/gif/bmp into the form which would then be imported into the
> dot
> file along with the answers to the other fields
Jonathan West - 25 Feb 2006 11:47 GMT
>A user would open up a word templete (.dot) file. The form embedded into
>the
> .dot file would prompt the user to fill out some fields, including one to
> attach a jpg/gif/bmp into the form which would then be imported into the
> dot
> file along with the answers to the other fields
Doug's approach is one way. Another is to include a MACROBUTTON field in the
document, like this
{ MACROBUTTON BrowseForPicture Double-click to insert a picture}, where the
{ } characters are field braces inserted by pressing Ctrl-F9.
Then the BrowseForPicture macro can display the Insert Picture dialog using
code based on what Doug has provided. To insert the picture into the
document, you may need to have the code temporarily unprotect the document,
insert the picture, and then re-protect the document.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup