SaveAs Crashes
Thank you. It turns out that my system has a glitch that causes a crash.
Another member of our team tried the code and it ran. I did use the KILL
command tied to a vba Kill function , the RptName.FileExists did not
recognize the command.
Thanks again.
"Henry" wrote:
Candyman,
Take out the two "Application.DisplayAlerts = False" and run it again.
I would think that, if the file already exists, Excel is asking for a new
name to save it under.
I don't know if you want to save it to the historical directory if the file
already exists.
If so, you'll need to delete the original version first.
If RptName.FileExists Then Kill RptName
Or, to leave the original in place
If RptName.FileExists Then Exit Sub
Henry
"Candyman" wrote in message
...
I run an application that opens another file, generates a report, then
saves
to another 2 directories. Part of that save is to a historical directory,
then to the "Current" directory. I believe the system is crashing because
there is an existing file in the folder. It creates some LOG then closes
Excel completly.
If I clear the folders then it runs perfectly. The files are created. If
i
uncomment the SetAttr line then it gives me a "cannot find file" error and
stops the code.
1) How do I get around the system crash?
2) How do i set file attribute to read only?
I am using:
RptName = ThisPath & "\" & "Reports" & "\ " & RptName & " " & Format(Date,
"yyyymmdd")
Application.DisplayAlerts = False
Application.DisplayAlerts = False
Sheets(ChannelName).Move
ActiveWorkbook.SaveAs Filename:=RptName
' SetAttr RptName, vbReadOnly
|