PC Review


Reply
Thread Tools Rate Thread

Allowing xlBook.SaveAs in Access code to overwrite existing workbook?

 
 
Ed from AZ
Guest
Posts: n/a
 
      26th Jan 2008
I'm making my first forays into Access with code. As part of a data
export sub, I create an instance of Excel and add a new workbook. I
create the name of the workbook with the date in it. As I'm testing
this, Excel keeps giving me a warning that a workbook already exists.
(All this is in Excel and Access 2003, by the way.)

How can I write the code in Access to allow Excel to overwrite the
previous file in the SaveAs?

Ed
 
Reply With Quote
 
 
 
 
Ed from AZ
Guest
Posts: n/a
 
      26th Jan 2008
Never mind - I took a different route. I use DIR to test for the file
name -if it exists, I add a number to it to make a new file name.

Ed

On Jan 26, 7:54*am, Ed from AZ <prof_ofw...@yahoo.com> wrote:
> I'm making my first forays into Access with code. *As part of a data
> export sub, I create an instance of Excel and add a new workbook. *I
> create the name of the workbook with the date in it. *As I'm testing
> this, Excel keeps giving me a warning that a workbook already exists.
> (All this is in Excel and Access 2003, by the way.)
>
> How can I write the code in Access to allow Excel to overwrite the
> previous file in the SaveAs?
>
> Ed


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      26th Jan 2008
That is one way.

Another way would be to use:

xlapp.displayalerts = false
'do the saveas
xlapp.displayalerts = true

where xlapp is an object variable that represents your instance of excel.

Another alternative (maybe) would be to include the date and time:

dim myFilename as string
myfilename = "c:\somefolder\someprefix" & format(now,"yyyymmdd_hhmmss") & ".xls"

I don't think I've ever saved a file within the same second.

Ed from AZ wrote:
>
> Never mind - I took a different route. I use DIR to test for the file
> name -if it exists, I add a number to it to make a new file name.
>
> Ed
>
> On Jan 26, 7:54 am, Ed from AZ <prof_ofw...@yahoo.com> wrote:
> > I'm making my first forays into Access with code. As part of a data
> > export sub, I create an instance of Excel and add a new workbook. I
> > create the name of the workbook with the date in it. As I'm testing
> > this, Excel keeps giving me a warning that a workbook already exists.
> > (All this is in Excel and Access 2003, by the way.)
> >
> > How can I write the code in Access to allow Excel to overwrite the
> > previous file in the SaveAs?
> >
> > Ed


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using SaveAs Statement to overwrite existing File Peter Microsoft Excel Programming 4 26th Mar 2010 06:26 AM
xlBook.SaveAs (documentName) when file open by another process bg_ie@yahoo.com Microsoft Excel Programming 2 15th Dec 2006 09:26 AM
SaveAs and always overwrite? =?Utf-8?B?TWF1cnkgTWFya293aXR6?= Microsoft Excel Programming 3 31st Oct 2005 04:16 PM
Q: overwrite during saveas =?Utf-8?B?SklNLkgu?= Microsoft Excel Misc 1 5th Jan 2005 07:27 PM
SaveAs - Stop the Overwrite box? Kenji Microsoft Excel Worksheet Functions 1 19th Feb 2004 06:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:09 AM.