Excel dynamic SaveAs w/ vb from Mr Excel


 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

dynamic SaveAs w/ vb
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

firefytr
Board Master
Board  Master


Joined: 09 Dec 2003
Posts: 1076
Location: Boardman, OR
Flag: Usa

Status: Offline

 Reply with quote  

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 icon_redface.gif (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

Post Wed Jan 21, 2004 7:45 pm 
 View user's profile Send private message

Cbrine
Board Master


Joined: 02 Dec 2003
Posts: 589

Flag: Canada

Status: Offline

 Reply with quote  

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?
_________________
Heisenberg may have slept here.

Post Wed Jan 21, 2004 7:57 pm 
 View user's profile Send private message

firefytr
Board Master
Board  Master


Joined: 09 Dec 2003
Posts: 1076
Location: Boardman, OR
Flag: Usa

Status: Offline

 Reply with quote  

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

Post Wed Jan 21, 2004 7:59 pm 
 View user's profile Send private message

Cbrine
Board Master


Joined: 02 Dec 2003
Posts: 589

Flag: Canada

Status: Offline

 Reply with quote  

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.
_________________
Heisenberg may have slept here.

Post Wed Jan 21, 2004 8:04 pm 
 View user's profile Send private message
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.