Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code to automatically overwrite?

I need to save my spreadsheet as part of my macro. The trouble is, th
worksheet already exists. How can I automatically get my sheet t
overwrite?

This is what I was using:
[vb]
ActiveWorkbook.SaveAs Filename:="C:\LEXPM1a.xls"
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False
_
CreateBackup:=False
[/vb

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Code to automatically overwrite?

Andy,

enclosing the code to save the file in the statements:

Application.DisplayAlerts=false
....
Application.DisplayAlerts=true

will suppress the replace file pop-up.

Pete.
-----Original Message-----
I need to save my spreadsheet as part of my macro. The

trouble is, the
worksheet already exists. How can I automatically get my

sheet to
overwrite?

This is what I was using:
[vb]
ActiveWorkbook.SaveAs Filename:="C:\LEXPM1a.xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="",

ReadOnlyRecommended:=False,
_
CreateBackup:=False
[/vb]


---
Message posted from http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Code to automatically overwrite?

Andy,

Haven't tried your code but do not see any obvious problem. Have you tried
it and get a problem?

Only couple of points I would add is that you can remove all of the
extraneous arguments, such as WriteResPassword, they are all defaults, and
you might want to precede the code with Application.DisplayAlerts = False,
so as to avoid the warning message. Remember to reset at the end.


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"andycharger " wrote in message
...
I need to save my spreadsheet as part of my macro. The trouble is, the
worksheet already exists. How can I automatically get my sheet to
overwrite?

This is what I was using:
[vb]
ActiveWorkbook.SaveAs Filename:="C:\LEXPM1a.xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
_
CreateBackup:=False
[/vb]


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to automatically test for file, update, overwrite Brent E Excel Discussion (Misc queries) 3 October 22nd 08 11:00 PM
Automatically starting code Richard Excel Worksheet Functions 3 February 8th 06 02:33 AM
Automatically running code Richard Excel Worksheet Functions 1 February 7th 06 09:35 PM
Running Code Automatically Bruno[_2_] Excel Programming 2 January 31st 04 06:26 AM
VBA code to automatically close file Kevin Excel Programming 4 November 6th 03 04:18 PM


All times are GMT +1. The time now is 12:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"