+ Reply to Thread
Results 1 to 8 of 8

change directory not working right

  1. #1
    Registered User
    Join Date
    10-19-2006
    Posts
    29

    change directory not working right

    Hi

    The below code is not behaving. I want the getopenfile to open at the location of the saved workbook. I've tried things like CurDir, but nothing seems to work and keeps reverting back to my directory (I'm at work so I: drive). The workbook is to be copied into different folders which is why I don't want to just hard code it.
    I've also searched the site for options and have used most of them! Any ideas?
    Thanks
    Andy

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    Did you try to use an instruction to change current drive, for example:
    Please Login or Register  to view this content.
    before to use the instruction:
    Please Login or Register  to view this content.
    I hope it can help.

    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    10-19-2006
    Posts
    29
    Hi Antonio

    I'm not sure I follow.
    I've tried hardcoding it chdir("g:\") but that did not work.

    Thanks
    Andy

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481
    Hi Crispie,

    Include the following statement before the ChDir statement in your code:
    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Best regards,

    Greg M

  5. #5
    Registered User
    Join Date
    10-19-2006
    Posts
    29
    Thanks Gregg

    That works wonders. Just out of interest how come just having the full file path doesn't work??

    Thanks again

  6. #6
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    If your path is on another active drive you need to change active drive and then path will run good.

    Regards,
    Antonio

  7. #7
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481
    Hi again Crispie,

    Many thanks for the feedback. You're welcome - delighted to have helped.

    Excel maintains an active path for each drive, but only one active drive. The GetOpenFilename command looks at whatever drive happens to be the active drive, and then at the active path on that drive. This is why you need to select the appropriate drive as well as the appropriate path.

    All the best,

    Greg M

  8. #8
    Registered User
    Join Date
    10-19-2006
    Posts
    29
    Good to know!!

    Thanks to both of you for your help! :o)

+ 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