browse and attach file

D

Denise

Is there a macro, field, or content control in Word 2007 that will allow the
user of a form to open the Browse window, select a file, and paste the
directory path of that file as a hyperlink into the form? InfoPath has a
control that does this, but I can't find one in Word.
 
D

Doug Robbins - Word MVP

Use

With Dialogs(wdDialogFileOpen)
If .Display <> -1 Then
BrowseFile = ""
Else
BrowseFile = WordBasic.FileNameInfo$(.Name, 1)
End If
End With
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, _
Address:=BrowseFile



--
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
 
D

Denise

Thank you Doug. I was able to open a "browse" window and select a file, but
it did not insert the directory path into the form. Any other suggestions?
: )
 
D

Doug Robbins - Word MVP

What sort of form is it? The code that I gave you inserts the hyperlink at
the location of the cursor in the active document.

--
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
 

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