dynamic SaveAs w/ vb

Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: dynamic SaveAs w/ vb

  1. #1
    MrExcel MVP Zack Barresse's Avatar
    Join Date
    Dec 2003
    Location
    Oregon, USA
    Posts
    10,693
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default dynamic SaveAs w/ vb

     
    is there a way to write code that will create a new file (i've got that), and save the new file as a specified file name - but, if that name already exists, will change the name (i.e. name, name1, name2, name3...) if it already exists?


    i'm not having luck finding this in help resources.

    oh, and one other (sorry about doubling up here)
    i have code which will close the original book
    Windows("Day_Report 4 Opacity 2003").Activate
    ActiveWindow.Close
    it always asks me if i want to save before closing (in lieu of changes, of course) and i never ever want to save. is there a way to bypass this?
    Regards,
    Zack Barresse
    My Book on Excel Tables
    My Blog @ ExcelTables.com
    (If you would like comments in any code, please say so.)

  2. #2
    Board Regular Cbrine's Avatar
    Join Date
    Dec 2003
    Location
    Brampton
    Posts
    3,196
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: dynamic SaveAs w/ vb

    In response to your second thing

    Activeworkbook.close false
    will eliminate the prompt to save issue.

    You might want to think about using the dir function to scan for the file save name in the default save folder prior to actually saving the file, if it finds the file name, then it increments a counter and check again?

  3. #3
    MrExcel MVP Zack Barresse's Avatar
    Join Date
    Dec 2003
    Location
    Oregon, USA
    Posts
    10,693
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: dynamic SaveAs w/ vb

    Cbrine,

    that dir function sounds just what i need. thank you for taking the time to post a reply, this helps me greatly.
    Regards,
    Zack Barresse
    My Book on Excel Tables
    My Blog @ ExcelTables.com
    (If you would like comments in any code, please say so.)

  4. #4
    Board Regular Cbrine's Avatar
    Join Date
    Dec 2003
    Location
    Brampton
    Posts
    3,196
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: dynamic SaveAs w/ vb

      
    FYI,
    I used the dir function in MS access, and you need to put it in a loop and I think you look for !EOF. Just put your check vs the filename within the loop and exit the loop if you find a match, update your filename with the counter and run the loop again, until if get's through the entire loop. So place your save code after the Loop command. It has it own internal counter or something to keep track of the last file displayed. So each time it's executed it grabs the next file.

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com