+ Reply to Thread
Results 1 to 8 of 8

Code to Open the Folder i just saved to in VBA?

  1. #1
    Forum Contributor
    Join Date
    04-13-2010
    Location
    England
    MS-Off Ver
    Office 2016 365
    Posts
    211

    Code to Open the Folder i just saved to in VBA?

    Hi,

    I've got code setup to save a load of worksheets as .pdf to a particular folder on the pc. At the end i want a msgbox that asks if the user wants to open the folder.

    Soim guessing it would be something like the below but i don't know the command to actually open the folder?

    Please Login or Register  to view this content.
    Thanks in advance

    J

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Code to Open the Folder i just saved to in VBA?

    Open the folder is what manner? Op the File Open dialogue prompt in Excel, open an instance of file explorer.exe positioned to that directory. I.e. what is the purpose?
    If you like my contribution click the star icon!

  3. #3
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Code to Open the Folder i just saved to in VBA?

    Does this work for you?

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    04-13-2010
    Location
    England
    MS-Off Ver
    Office 2016 365
    Posts
    211

    Re: Code to Open the Folder i just saved to in VBA?

    Hi the purpose is simply to open up the folder where i sent my files - so for the user to view the contents of the folder as you would normally when double clicking on any folder.

    rkey - thanks for that bit of code, it opens up the browser to select a folder but doesn't actually just open the folder .

  5. #5
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Code to Open the Folder i just saved to in VBA?

    then try this:

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    04-13-2010
    Location
    England
    MS-Off Ver
    Office 2016 365
    Posts
    211

    Re: Code to Open the Folder i just saved to in VBA?

    you sir. are a genius. That has worked perfectly. Thanks.

    For my own knowledge, what is "retVal" and why don't i have to declare it?

  7. #7
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Code to Open the Folder i just saved to in VBA?

    retVal stands for return value.

    The Shell command returns a value (so you can determine if the command succeeded e.g.) which you can use for error handling or other comparisons.

    Actually you should declare it, unless you are running your macro without "Option Explicit"
    To actually force yourself in declaring the right type of values you could consider getting used the the habit of declaring (unfortunately I'm not :P).
    It also could improve performace as I believe.

    Cheers,
    Rick

  8. #8
    Forum Contributor
    Join Date
    04-13-2010
    Location
    England
    MS-Off Ver
    Office 2016 365
    Posts
    211

    Re: Code to Open the Folder i just saved to in VBA?

    Cheers mate, thanks very much for the help

+ Reply to 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