ChangeFileOpenDirectory Problem

R

RW

I am using Windows XP (sp2). Word 2002 (sp3)

I am trying to open a particular directory within VBA using With
Dialogs(wdDialogInsertPicture) command. For some reason, it does not want to
work correctly.
Everything is Dim'd correctly and the DirName string populates correctly.
Here's my code: Please Help.

DirName = PhotoDir & ChemName & "\"
ChangeFileOpenDirectory DirName
Selection.HomeKey Unit:=wdLine
Selection.TypeText Text:="" + vbTab
Selection.TypeText Text:="" + vbTab
VPRP = Selection.Information(wdVerticalPositionRelativeToPage)
HPRP = Selection.Information(wdHorizontalPositionRelativeToPage)
With Dialogs(wdDialogInsertPicture)
If .Display = 0 Then
Exit Sub
Else
PhotoFile = .Name
End If
End With
 
D

Dave Lett

Hi RW,

wdDialogInsertPicture is not the FileOpen dialog; therefore,
ChangeFileOpenDirectory does _not_ affect what you're doing with the
wdDialogInsertPicture dialog. Try this instead:

Dim sDefault As String
Dim sDirName As String
sDirName = "C:\Test\"
'''store the default path
sDefault = Options.DefaultFilePath(wdPicturesPath)
'''change the default path
Options.DefaultFilePath(wdPicturesPath) = sDirName
'''show the dialog box
With Dialogs(wdDialogInsertPicture)
.Display
End With
'''reset to the default path
Options.DefaultFilePath(wdPicturesPath) = sDefault

HTH,
Dave
 
R

RW

Thanks! That worked.

Rick

Dave Lett said:
Hi RW,

wdDialogInsertPicture is not the FileOpen dialog; therefore,
ChangeFileOpenDirectory does _not_ affect what you're doing with the
wdDialogInsertPicture dialog. Try this instead:

Dim sDefault As String
Dim sDirName As String
sDirName = "C:\Test\"
'''store the default path
sDefault = Options.DefaultFilePath(wdPicturesPath)
'''change the default path
Options.DefaultFilePath(wdPicturesPath) = sDirName
'''show the dialog box
With Dialogs(wdDialogInsertPicture)
.Display
End With
'''reset to the default path
Options.DefaultFilePath(wdPicturesPath) = sDefault

HTH,
Dave
 

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