+ Reply to Thread
Results 1 to 5 of 5

How to save a copy of the workbook to a specified path?

  1. #1
    Registered User
    Join Date
    10-03-2013
    Location
    california
    MS-Off Ver
    Excel 2007
    Posts
    34

    How to save a copy of the workbook to a specified path?

    Hi,

    I am working on a code that sends and email with a renamed workbook attachment. I would like to save a copy of the workbook to a specific folder "C:/desktop" instead of killing the temporary file.

    I have tried a lot of things that my limited knowledge would allow me but I can't make it work. Your help is appreciated!

    Please Login or Register  to view this content.
    Last edited by moxman; 10-18-2013 at 01:20 AM.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: How to save a copy of the workbook to a specified path?

    didnt read the whole code but having two "\" in the path could be the issue

    MyPath = "C:\Documents and Settings\\Desktop"
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    10-03-2013
    Location
    california
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: How to save a copy of the workbook to a specified path?

    Quote Originally Posted by humdingaling View Post
    didnt read the whole code but having two "\" in the path could be the issue

    MyPath = "C:\Documents and Settings\\Desktop"
    Hi, Thanks for pointing that out. Its a mistake I made while posting the code here. The original code goes to a different specific folder, I just changed it to the Desktop for easier reference.

    I have been focusing on the line:
    Please Login or Register  to view this content.
    tried changing it to wb2.Saveas.Filename etc etc but didn't work

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: How to save a copy of the workbook to a specified path?

    The code you have already saves the file but in a tempfolder
    under windows 7
    TempFilePath = Environ$("temp") & "\" was saving to C:\Users\<username>\AppData\Local\temp\

    to change to desktop
    Please Login or Register  to view this content.
    i run windows 7, different windows may have different desktop path, adjust to your windows default
    Last edited by humdingaling; 10-20-2013 at 07:40 PM.

  5. #5
    Registered User
    Join Date
    10-03-2013
    Location
    california
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: How to save a copy of the workbook to a specified path?

    WOW! That worked! Thanks a lot humdingaling!

    I also disabled the code
    Please Login or Register  to view this content.
    to prevent it from deleting the newly created form.

    Thank you for your help! Its a very useful addition to help me understand VBA.

+ 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. how can I add a path where to save the new workbook?
    By simeonmein in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-10-2013, 03:33 PM
  2. [SOLVED] Save a workbook to a folder path in textbox2 using textbox1 as filename
    By yoko21 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-24-2013, 03:59 AM
  3. Path name invalid when trying to save a workbook - VBA
    By Jamiec94 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-17-2013, 12:42 PM
  4. Copy Range from Excel and Paste it in MS Word and then save it in a specified path
    By prasadcherry in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-10-2012, 02:29 PM
  5. Save Workbook using name and path in a cell
    By adinic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-11-2007, 01:27 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