+ Reply to Thread
Results 1 to 12 of 12

Save and Close to a specific folder

  1. #1
    Registered User
    Join Date
    10-02-2017
    Location
    Swansea
    MS-Off Ver
    2007
    Posts
    14

    Save and Close to a specific folder

    Hi I have the code below that is working fine but ever now and then it will save in a random folder on one of our many shared drives.

    How do i get it to save to a specific folder very time.

    Thanks in advance

    Code:
    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 11-21-2019 at 08:36 PM. Reason: Please use code tags!

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Save and Close to a specific folder

    If you want to save in the same place every time, then you can use the active path.

    Maybe this will help you get started

    Please Login or Register  to view this content.
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    10-02-2017
    Location
    Swansea
    MS-Off Ver
    2007
    Posts
    14

    Re: Save and Close to a specific folder

    Thanks for the quick reply, sorry being a bit thick, will that work if I insert a

    “call” xxxx sub, just below the savechanges part?

    Thanks again

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Save and Close to a specific folder

    It all depends on what you are tying to do. Maybe a little bit more explanation on what you are trying to achieve?

  5. #5
    Registered User
    Join Date
    10-02-2017
    Location
    Swansea
    MS-Off Ver
    2007
    Posts
    14

    Re: Save and Close to a specific folder

    Hi thanks again for getting back to me,

    So I have a large excel that has loads of macros running, the sheet is accessed by loads of different people, the aboveboard macro is used to auto save and close the sheet after it’s been idle for a set time ( triggered by another macro.

    What has been happening is it is randomly saving different folders, I want to be able to force it to only save in one particular location.

    Hope that helps

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,701

    Re: Save and Close to a specific folder

    I think we'll need more information.

    Please Login or Register  to view this content.
    That should save the file in the same place it was opened from, not in a new (or random location).

    It is possible that you have code somewhere else that is causing the issue. What is the code for Sub RO_Close?

    Is there a SaveAs method call anywhere in your existing code?

    It would help if you could share the file so we can see all the code. The paper clip icon does not work for attachments. To attach a file, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.
    Last edited by 6StringJazzer; 11-23-2019 at 03:03 PM.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,368

    Re: Save and Close to a specific folder

    Agree with 6SJ: given the code presented, you would expect it to save in the same place. UNLESS, you have code elsewhere that changes the Active Workbook. Note that the ActiveWorkbook is not necessarily the same as ThisWorkbook. ThisWorkbook is the workbook running the code.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,368

    Re: Save and Close to a specific folder

    Or, maybe another user opens another workbook or two so the ActiveWorkbook is not what you think it is ... but that would maybe closing the wrong workbook, not saving yours in the wrong place ... just thinking out loud

  9. #9
    Registered User
    Join Date
    10-02-2017
    Location
    Swansea
    MS-Off Ver
    2007
    Posts
    14

    Re: Save and Close to a specific folder

    Hi all thats fantastic, thanks for the help, I’ll get a copy of the system ASAP and up load it.

    You have already answered the main question I had that it should save in the original location, but I think TMS has hit the nail on the head without realising it, I have a few different sheets and I have used ActiveWorkbook not ThisWorkbook, do code in other sheets could be triggering the close down.

    Thanks very much for the help already I will upload a copy ASAP.

  10. #10
    Registered User
    Join Date
    10-02-2017
    Location
    Swansea
    MS-Off Ver
    2007
    Posts
    14

    Re: Save and Close to a specific folder

    Hi please see attached I've had to cut a lot of the sheets out to get it on but the macros are still there, I have removed the passwords I think if not it should be "Master1"

    any help would be fantastic, ps i have changed all the ActiveWorkbook to ThisWorkbook
    Attached Files Attached Files

  11. #11
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,701

    Re: Save and Close to a specific folder

    I see only one reference to ActiveWorkbook and it is to protect sheet Master1 (that should be changed to ThisWorkbook, but it isn't causing your problem). I don't see anyplace where another file is created or opened.

    I'm going to see if I can do any testing with your file. Not sure what will happen with stuff missing.

  12. #12
    Registered User
    Join Date
    10-02-2017
    Location
    Swansea
    MS-Off Ver
    2007
    Posts
    14

    Re: Save and Close to a specific folder

    Top man, the sheets I removed were just other months, I really appreciate you help.

+ 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. [SOLVED] Open files in folder, replace comma with semicolon etc, save and close
    By soreno in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-29-2019, 07:01 AM
  2. [SOLVED] Save a copy of Workbook on Close to a different folder.
    By bubai in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-12-2017, 04:37 AM
  3. Replies: 1
    Last Post: 10-18-2014, 05:04 PM
  4. [SOLVED] macro to open all files in a folder, save them, then close them
    By hopefulhart in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-27-2013, 06:40 PM
  5. [SOLVED] What is wrong with this code? (Loop through WBs in folder - open, edit, save & close)
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-04-2013, 07:49 PM
  6. Need macro to open, refresh, save, close 50 workbooks in a folder.
    By paulcg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2012, 09:23 AM
  7. I like to open a folder,auto print,save then close
    By tied of opening files in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2005, 06: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