+ Reply to Thread
Results 1 to 7 of 7

Saving to a changing directory Help. Not sure how to replace %~dp0

  1. #1
    Registered User
    Join Date
    10-09-2012
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    14

    Saving to a changing directory Help. Not sure how to replace %~dp0

    Because people can't save files properly for me, I had to automate saving for them, based on cell data, to keep our files organized. I pieced this together a few years ago and it has worked great. On a single computer. But, now I'm trying to use it in conjunction with the Google Drive. My problem is static destination doesn't exist anymore. Every computer saving there will have a different location.
    (ex "C:\users\wkemmerer\Google Drive\Summaries" on one computer and "C:\users\CW313-B\Google Drive\Summaries" and so on)
    With a batch file I just use "%~dp0Summaries" and I would be fine. But I know that isn't going to work in VB. So... What can I do here to deal with the floating directory names? Keep in mind, this isn't off of a template. I need to be able to open the last saved file, make this quarters changes, and SaveAs again. Creating an organized history.


    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Saving to a changing directory Help. Not sure how to replace %~dp0

    Hi illogicalmind. Congratulations on your first post. Thank you for using CODE TAGS.

    It seems like your paths use the 'User Name', which you may be able to retrieve using a 'Bulit In' Windows Environment variable.
    Please Login or Register  to view this content.
    Lewis

  3. #3
    Registered User
    Join Date
    10-09-2012
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    14

    Re: Saving to a changing directory Help. Not sure how to replace %~dp0

    Thank you for the reply. I should add that I've learned just enough logic to make simple things work. So I'll have to do some research on what you've given me.

    I didn't realize it was my first post. I have just been lurking forever apparently...

  4. #4
    Registered User
    Join Date
    10-09-2012
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    14

    Re: Saving to a changing directory Help. Not sure how to replace %~dp0

    The idea worked great, Thank you. All I need now is to use the server based login that I'm using and not the actual username. My computer is wkemmerer, but my google drive saves under wkemmerer.CWM (this is not the case with the computers that are in question, so you have solved my problem. I just want to expand on the capability)

    I'm sure this could be cleaned up, but here is what I'm working with now

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-09-2012
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    14

    Re: Saving to a changing directory Help. Not sure how to replace %~dp0

    I switched to Environ("USERPROFILE") got it rewritten. Working so far. This forum has been awesome for me. Thanks again lewis

    Please Login or Register  to view this content.
    Last edited by illogicalmind; 12-16-2015 at 11:01 AM.

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Saving to a changing directory Help. Not sure how to replace %~dp0

    I'm glad I was able to help. 'USERNAME' and 'USERPROFILE' are just two of the possibilities you can use. If you need something more in the future, permanent Environment variable names and values of your choosing can be put on each computer by someone with Administrative Privileges.

    Lewis
    Last edited by LJMetzger; 12-16-2015 at 05:37 PM.

  7. #7
    Registered User
    Join Date
    10-09-2012
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    14

    Re: Saving to a changing directory Help. Not sure how to replace %~dp0

    Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. trouble with saving file to directory
    By gbm64 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-23-2013, 09:53 PM
  2. Saving file in current directory after accessing file in another directory
    By vuxsa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-28-2011, 11:37 AM
  3. Not saving in right directory....
    By hutch@edge.net in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2008, 10:01 AM
  4. Conditional saving in a given directory, with always changing file name
    By hunsnowboarder in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-24-2007, 12:26 PM
  5. Saving to root directory
    By ChrisP in forum Excel General
    Replies: 2
    Last Post: 07-30-2006, 09:15 PM
  6. help with making a directory and saving the spreadsheet
    By jeffhughes@ntlworld.com in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-12-2006, 08:20 AM
  7. [SOLVED] Setting Directory when Saving File
    By David in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-28-2005, 10:35 PM
  8. Saving into new directory
    By Greg B in forum Excel General
    Replies: 2
    Last Post: 03-02-2005, 12:06 PM

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