PC Review


Reply
Thread Tools Rate Thread

Saving an Excel worksheet

 
 
Marius from Rome
Guest
Posts: n/a
 
      7th Jan 2004
My Access application opens an existing Excel worksheet and inserts data in
it.
My application should give my worksheet a new file name (i.e.
newworksheet.xls), save and close it.
I attempted using the .saveas and .close methods, but if a file with the
same name altrady exists I don't get any error while the user is prompted to
save changes in the original file.
Can anybody please suggest the best and simplest way to check if a file with
the new name already exists and/or to overwrite it?
Regards
marius



 
Reply With Quote
 
 
 
 
John Nurick
Guest
Posts: n/a
 
      7th Jan 2004
Hi Marius,

You can use the Dir() function, something like this:

Dim strNewName as String

strNewName = "newworksheet.xls"
With MyWorksheet
If Len(Dir(.Path & "\" & strNewName)) > 0 Then
'File already exists
Kill .Path & "\" & strNewname
End If
.SaveAs strNewName
.Close
End With


On Wed, 7 Jan 2004 17:23:38 +0100, "Marius from Rome"
<(E-Mail Removed)> wrote:

>My Access application opens an existing Excel worksheet and inserts data in
>it.
>My application should give my worksheet a new file name (i.e.
>newworksheet.xls), save and close it.
>I attempted using the .saveas and .close methods, but if a file with the
>same name altrady exists I don't get any error while the user is prompted to
>save changes in the original file.
>Can anybody please suggest the best and simplest way to check if a file with
>the new name already exists and/or to overwrite it?
>Regards
>marius
>
>


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
 
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
FYI Excel 2007: Saving a xlsm file with a hidden worksheet activated makes worksheet visible David G. Microsoft Excel Programming 0 3rd Aug 2009 07:16 PM
data from excel worksheet update with another excel worksheet tonycd Microsoft Excel Worksheet Functions 8 18th May 2009 09:14 AM
data from excel worksheet update with another excel worksheet tonycd Microsoft Excel Worksheet Functions 0 18th May 2009 04:54 AM
Excel 2007 error msg when saving - "Errors were detected while saving FILENAME. Excel may be able to save the file by removing or repairing some features" Tim Microsoft Excel Discussion 1 15th Jul 2008 12:18 AM
EXCEL question saving a file saving the the first column as read only Luis Esteban Valencia Microsoft ASP .NET 0 6th Jan 2005 08:02 PM


Features
 

Advertising
 

Newsgroups
 


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