Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default SaveAs Crashes

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default SaveAs Crashes

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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default 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





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
SaveAs - VBA Jae Excel Discussion (Misc queries) 0 April 10th 08 06:04 AM
VBA SaveAs Value charlie Excel Discussion (Misc queries) 4 August 27th 07 11:33 PM
SaveAs Stan Halls Excel Worksheet Functions 5 November 28th 06 07:51 PM
Help with SaveAs Glen Mettler[_2_] Excel Programming 1 January 29th 04 05:32 PM
SaveAs,csv popo pop Excel Programming 2 October 31st 03 06:08 AM


All times are GMT +1. The time now is 07:25 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"