Show FileOpen with a specified location

Discussion in 'Word Programming' started by Cooz, Mar 19, 2009.

  1. Cooz

    Cooz Guest

    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
     
    Cooz, Mar 19, 2009
    #1
    1. Advertisements

  2. Cooz

    Jay Freedman Guest

    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.

    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
     
    Jay Freedman, Mar 19, 2009
    #2
    1. Advertisements

  3. Cooz

    Cooz Guest

    Thank you Jay, that seems to do the trick.

    "Jay Freedman" wrote:

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

    >
    >
    >
     
    Cooz, Apr 10, 2009
    #3
  4. Cooz

    mettleurge

    Joined:
    Nov 26, 2013
    Messages:
    2
    Likes Received:
    0
    Nope, Doesn't work in Word2010.

     
    mettleurge, Nov 26, 2013
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    121
  2. Tony

    File location

    Tony, May 7, 2006, in forum: Word Programming
    Replies:
    2
    Views:
    74
    Jonathan West
    May 7, 2006
  3. Jared L

    Range location versus character count

    Jared L, Jun 19, 2006, in forum: Word Programming
    Replies:
    3
    Views:
    109
    Jezebel
    Jun 20, 2006
  4. Doctorjones_md

    Directing/Specifying a Print Request/Location

    Doctorjones_md, May 22, 2007, in forum: Word Programming
    Replies:
    9
    Views:
    91
    Albert D. Kallal
    May 27, 2007
  5. CyD
    Replies:
    1
    Views:
    115
    Michael Bednarek
    May 25, 2007
  6. Neil

    Getting Custom.dic Location

    Neil, Nov 15, 2007, in forum: Word Programming
    Replies:
    2
    Views:
    154
  7. Cooz
    Replies:
    1
    Views:
    216
    Graham Mayor
    Apr 10, 2009
  8. Joe Trapani
    Replies:
    0
    Views:
    404
    Joe Trapani
    Jan 10, 2011
Loading...