Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Word: How to point to a specified dir when a file dialog is open?

Status
Not open for further replies.

sharon3874

Programmer
Oct 27, 2006
24
US
in VBA word, when I right click on some text, I can add hyperlinks upon the text. It will open up a file dialog allowing me to navigate and pick a file. My question is that how I can force the dialog box to point to a certain directory when it opens up?

Thanks a lot.
 
Just put the path you want in the "Type the file or web page name" box. If you want to do it in VBA:

Code:
Option Explicit

Sub aTest()
    
Dim sLink As String
Dim sLinkText As String

sLink = "C:\Documents and Settings\<[i]user[/i]>\My Documents"
sLinkText = "This is the text"

    ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
        sLink, SubAddress:="", ScreenTip:="", TextToDisplay:=sLinkText
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top