Closed Thread
Results 1 to 4 of 4

Selecting Default Folder in Open File Dialogue Box Problem

  1. #1
    Registered User
    Join Date
    03-25-2004
    Posts
    54

    Selecting Default Folder in Open File Dialogue Box Problem

    I am working on an Excel97 database of clients. For each client the system creates a folder in which are stored the attendance notes etc as Word documents. The path of these folders is:

    P:\Client Details\Year\Month sheet name\05_####\ where #### is the client's unique number for that year.

    When a user searches for a particular client I want to create a macro to open that client's folder and then be able to open any of the word docs in it.

    I have been able to do the later part with the following code:

    Sub OpenWordFiles()

    fileToOpen = Application.GetOpenFilename("Text Files (*.doc), *.doc")

    Set wdApp = CreateObject("word.application")
    wdApp.Documents _
    .Open(fileToOpen, ReadOnly:=False) _
    .Application.Visible = True
    With wdApp
    .Visible = True
    .WindowState = 1
    End With

    wdApp.Activate

    End Sub

    However I don't know how to get the Open File dialoge box to have first selected the relevant folder with the required files in it.

    Any help with this would be much appreciated,

    Paul

  2. #2
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Selecting Default Folder in Open File Dialogue Box Problem

    Try using Application.DefaultFilePath. It works for Excel2003. Not sure for Excel97.

  3. #3
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264

    Re: Selecting Default Folder in Open File Dialogue Box Problem

    You need to change to the current drive and current directory before you call GetOpenFilename:

    Please Login or Register  to view this content.
    Richard
    Richard Schollar
    Microsoft MVP - Excel

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Selecting Default Folder in Open File Dialogue Box Problem

    Guys, this thread is 5 years old.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1