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

I jumped the gun thinking I had it figured out...

I'm trying to bulletproof a spreadsheet template against being overwritten
by coworkers who must use it. I have set it up to force them to save it as
a normal Excel spreadsheet under a different name any time the template is
activated. All works fine unless I choose NOT to overwrite an existing
file.

To be clear, the saveas dialog appears and I choose a file name that already
exists. I am then asked if I wish to overwrite the file. If I say 'Yes'
everything goes fine. However, choosing 'No' or 'Cancel' results in an
error.

Here's a simplified example of what I have so far:

Sub SaveAsX()
NameFile:
On Error GoTo SaveAsErrors
FileSaveName = "Test"
While FileSaveName = "Test"
FileSaveName = Application.GetSaveAsFilename(InitialFileName:= _
"C:\temp\Test", fileFilter:="Microsoft Excel Workbook (*.xls),
*.xls")
Wend
ThisWorkbook.SaveAs Filename:=FileSaveName, FileFormat:=-4143
Exit Sub

SaveAsErrors:
If Err.Number = 1004 Then GoTo NameFile
End Sub

If I choose 'No' or 'Cancel' the first time the error is handled fine, the
SaveAs dialog box appears again. However, if I choose either button again
the second time it creates the same error but it is not caught by the error
trap. Why is this. Help!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default More SaveAs trouble

GOT IT!! I really hate feeling like I have hit a brick wall, asking for
help, and then finding the answer. Seems to inspire me, though.

"Shawn Shuler" wrote in message
...
I jumped the gun thinking I had it figured out...

I'm trying to bulletproof a spreadsheet template against being overwritten
by coworkers who must use it. I have set it up to force them to save it

as
a normal Excel spreadsheet under a different name any time the template is
activated. All works fine unless I choose NOT to overwrite an existing
file.

To be clear, the saveas dialog appears and I choose a file name that

already
exists. I am then asked if I wish to overwrite the file. If I say 'Yes'
everything goes fine. However, choosing 'No' or 'Cancel' results in an
error.

Here's a simplified example of what I have so far:

Sub SaveAsX()
NameFile:
On Error GoTo SaveAsErrors
FileSaveName = "Test"
While FileSaveName = "Test"
FileSaveName = Application.GetSaveAsFilename(InitialFileName:= _
"C:\temp\Test", fileFilter:="Microsoft Excel Workbook (*.xls),
*.xls")
Wend
ThisWorkbook.SaveAs Filename:=FileSaveName, FileFormat:=-4143
Exit Sub

SaveAsErrors:
If Err.Number = 1004 Then GoTo NameFile
End Sub

If I choose 'No' or 'Cancel' the first time the error is handled fine, the
SaveAs dialog box appears again. However, if I choose either button again
the second time it creates the same error but it is not caught by the

error
trap. Why is this. Help!




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[_3_] Excel Discussion (Misc queries) 4 April 10th 08 08:10 PM
SaveAs Stan Halls Excel Worksheet Functions 5 November 28th 06 07:51 PM
SaveAs Bill[_19_] Excel Programming 1 January 27th 04 11:11 PM
SaveAs Darrin Henry Excel Programming 0 September 12th 03 10:09 PM
SaveAs Dave Peterson[_3_] Excel Programming 1 September 12th 03 12:44 AM


All times are GMT +1. The time now is 02:50 PM.

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

About Us

"It's about Microsoft Excel"