+ Reply to Thread
Results 1 to 6 of 6

Save copy to newly created directory in the existing folder structure

  1. #1
    Registered User
    Join Date
    04-03-2010
    Location
    Orlando, FL
    MS-Off Ver
    Office 365
    Posts
    94

    Save copy to newly created directory in the existing folder structure

    I thought this wouldn't be too hard, but it's defeating me...
    I want to create a copy of a file in a folder created by the VBA code. I've tried this with limited success:
    Please Login or Register  to view this content.
    The folder is created, but the default "save to" location is still the parent folder. Also, I want to be able to save it as an .xlsm format, but it's defaulting to .xlsx. Thanks in advance...

    ...this was originally posted here: http://www.mrexcel.com/forum/excel-q...ml#post4196065
    but I didn't get any good responses.

  2. #2
    Forum Contributor S O's Avatar
    Join Date
    06-25-2015
    Location
    England
    MS-Off Ver
    Office 2010 + 2013 + 2016
    Posts
    103

    Re: Save copy to newly created directory in the existing folder structure

    Why do you need the dialog?

    Please Login or Register  to view this content.
    Also, nPath is the workbooks own path, so what path are you expecting it to change to with ChDir() ? is nPath on another drive? If so you will need to use
    Please Login or Register  to view this content.
    before ChDir().

  3. #3
    Registered User
    Join Date
    04-03-2010
    Location
    Orlando, FL
    MS-Off Ver
    Office 365
    Posts
    94

    Re: Save copy to newly created directory in the existing folder structure

    Hello, I added ChDir in an effort to somehow get the file to save into that directory. See attached photos... When I step through the code I see that the correct path name is assigned, but still the file "wants" to be saved to the old directory... 2015-06-26_133222.pngCropImage.png

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Save copy to newly created directory in the existing folder structure

    Since you have already know the target of copy operation, you don't need a GUI dialog box for this.

    Please Login or Register  to view this content.

    Regards
    Last edited by karedog; 06-26-2015 at 08:21 AM.

  5. #5
    Forum Contributor S O's Avatar
    Join Date
    06-25-2015
    Location
    England
    MS-Off Ver
    Office 2010 + 2013 + 2016
    Posts
    103

    Re: Save copy to newly created directory in the existing folder structure

    try adding another "\" at the end of fName....

  6. #6
    Registered User
    Join Date
    04-03-2010
    Location
    Orlando, FL
    MS-Off Ver
    Office 365
    Posts
    94

    Re: Save copy to newly created directory in the existing folder structure

    Thanks Karedog. It works fine with one exception - the code stops running a the "ThisWorkbook.Save" command. I commented it out and everything runs as advertised.

+ 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. Creating a file in a newly created folder.
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-12-2010, 03:01 PM
  2. How to copy to newly created sheet and save as PDF?
    By joanneb in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-30-2009, 04:05 PM
  3. Saving Workbook in newly created directory
    By sgreni in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-19-2009, 11:42 AM
  4. Newly Created Sheets Replacing Existing
    By degmania in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-20-2008, 04:04 PM
  5. Replies: 3
    Last Post: 07-25-2006, 02:35 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