Results 1 to 2 of 2

Thread: the "Open" dialog default path...

  1. #1

    Thread Starter
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860

    the "Open" dialog default path...

    I want to have the application.showOpenDialog (or similar) in excel to start in a predetermined folder. I'm having trouble because:

    1 - The only method I found was to change the actual default path, which would not be a plus for a program
    2 - Method 1 doesn't work (and I won't use it anyways), I recorded a macro of changing the filepath but apparently if I set it using code it doesn't "get through" to excel (maybe events were off?).

    Does anyone know how to have it open where I want it to?
    Don't pay attention to this signature, it's contradictory.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: the "Open" dialog default path...

    You could just save the default path and then change it to where you need just before calling it. Then after
    the file has been selected you can chage it back.

    VB Code:
    1. Dim sDefPath As String
    2. '...
    3. sDefPath = Application.DefaultFilePath
    4. Application.GetOpenFilename("Text Files (*.txt), *.txt")
    5. 'Do your open stuff.
    6. '...
    7. 'Set the path back.
    8. Application.DefaultFilePath = sDefPath
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width