Show FileOpen with a specified location

C

Cooz

Hi everyone,

How do I - in Word 2003 - show the file open dialog displaying a specified
location, for example the Startup path? The following examples won't work;
the only thing they accomplish is to display "All files (*.*)" - which they
should.

Sub FileOpenStartUp()
Dim dlgFileOpen As Dialog

Set dlgFileOpen = Application.Dialogs(wdDialogFileOpen)
With dlgFileOpen
.Name = Application.Options.DefaultFilePath(wdStartupPath) &
"\*.*"
.Show
End With
Set dlgFileOpen = Nothing

End Sub

---

Sub FileOpenStartUp()
Dim dlgFileOpen As Dialog
Dim strDocPath As String

strDocPath = Application.Options.DefaultFilePath(wdDocumentsPath)
Application.Options.DefaultFilePath(wdDocumentsPath) =
Application.Options.DefaultFilePath(wdStartupPath)

Set dlgFileOpen = Application.Dialogs(wdDialogFileOpen)
With dlgFileOpen
.Name = "*.*"
.Show
End With
Set dlgFileOpen = Nothing

Application.Options.DefaultFilePath(wdDocumentsPath) = strDocPath
End Sub

---

Sub FileOpenStartUp()
Dim dlgFileOpen As Dialog
Dim strCurrentDir As String

strCurrentDir = CurDir
ChDrive Application.Options.DefaultFilePath(wdStartupPath)
ChDir Application.Options.DefaultFilePath(wdStartupPath)

Set dlgFileOpen = Application.Dialogs(wdDialogFileOpen)
With dlgFileOpen
.Name = "*.*"
.Show
End With
Set dlgFileOpen = Nothing

ChDrive strCurrentDir
ChDir strCurrentDir
End Sub

---

Any help here will be greatly appreciated.

Thank you,
Cooz
 
J

Jay Freedman

Remove the "*.*" and leave just the "\" at the end of the .Name.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
C

Cooz

Thank you Jay, that seems to do the trick.

Jay Freedman said:
Remove the "*.*" and leave just the "\" at the end of the .Name.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
Joined
Nov 26, 2013
Messages
2
Reaction score
0
Nope, Doesn't work in Word2010.

Remove the "*.*" and leave just the "\" at the end of the .Name.

--
Regards,
Jay Freedman
Microsoft Word MVP FA
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Cooz wrote:
> Hi everyone,
>
> How do I - in Word 2003 - show the file open dialog displaying a
> specified location, for example the Startup path? The following
> examples won't work; the only thing they accomplish is to display
> "All files (*.*)" - which they should.
>
> Sub FileOpenStartUp()
> Dim dlgFileOpen As Dialog
>
> Set dlgFileOpen = Application.Dialogs(wdDialogFileOpen)
> With dlgFileOpen
> .Name = Application.Options.DefaultFilePath(wdStartupPath)
> & "\*.*"
> .Show
> End With
> Set dlgFileOpen = Nothing
>
> End Sub
>
> ---
>
> Sub FileOpenStartUp()
> Dim dlgFileOpen As Dialog
> Dim strDocPath As String
>
> strDocPath = Application.Options.DefaultFilePath(wdDocumentsPath)
> Application.Options.DefaultFilePath(wdDocumentsPath) =
> Application.Options.DefaultFilePath(wdStartupPath)
>
> Set dlgFileOpen = Application.Dialogs(wdDialogFileOpen)
> With dlgFileOpen
> .Name = "*.*"
> .Show
> End With
> Set dlgFileOpen = Nothing
>
> Application.Options.DefaultFilePath(wdDocumentsPath) = strDocPath
> End Sub
>
> ---
>
> Sub FileOpenStartUp()
> Dim dlgFileOpen As Dialog
> Dim strCurrentDir As String
>
> strCurrentDir = CurDir
> ChDrive Application.Options.DefaultFilePath(wdStartupPath)
> ChDir Application.Options.DefaultFilePath(wdStartupPath)
>
> Set dlgFileOpen = Application.Dialogs(wdDialogFileOpen)
> With dlgFileOpen
> .Name = "*.*"
> .Show
> End With
> Set dlgFileOpen = Nothing
>
> ChDrive strCurrentDir
> ChDir strCurrentDir
> End Sub
>
> ---
>
> Any help here will be greatly appreciated.
>
> Thank you,
> Cooz
 

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