PDA

View Full Version : SaveAs Command to Overwrites a Excel File



megha
02-08-2011, 09:27 AM
I am using the following code to SaveAS my workbook at the same location with the same file name. In other words - Workbook.SaveAs command that automatically overwrites a file with the same file name without prompting for a overwriting the file. This code works fine on my “c” drive but do not work on the website. I would appreciate any help. Thank you so much.
Private Sub CommandButton1_Click()
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Filename:= "http://sptdsrefining.etc. etc. Work List.xls (http://sptdsrefining.etc.%20etc.%20work%20list.xls/)"
Application.DisplayAlerts = True
ActiveWorkbook.Close
End Sub

mancubus
02-08-2011, 09:50 AM
hi.



A filename cannot contain any of the following characters: \ / : * ? " < > |



http://support.microsoft.com/kb/177506

megha
02-08-2011, 10:53 AM
Hello Mancubus: i am not expert with VBA. can you please help?

JP2112
02-08-2011, 11:00 AM
What mancubus is saying is that filenames in Windows cannot contain slashes or colons. So you cannot save it to a web site as you are attempting to do.

dicepackage
02-08-2011, 11:01 AM
EDIT: Ignore my post my solution would not work.

mancubus
02-08-2011, 11:32 AM
thanks JP.

and for saving as web page:

http://msdn.microsoft.com/en-us/library/aa221573(v=office.11).aspx

JP2112
02-08-2011, 12:33 PM
You can save a workbook as an HTML file, but AFAIK there's no mechanism built into Excel for saving a workbook to a website.