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

I have created the following macro, which is supposed to save the file based
on values in specific cells and then exit Excel, but it needs to be modified
to not save the file if the users clicks on the cancel button in the SaveAs
dialog box. I am a novice when it comes to this so any assistance with
specific examples will be greatly appreciated.

Sub saveexit()
'
' saveexit1 Macro
' Macro recorded 03/31/2008 by Barry Lerman
'
'
With ActiveWindow
strDate = Range("d2")
strDate1 = Format(Range("L2"), "mm-dd-yy")
Application.Dialogs(xlDialogSaveAs).Show _
arg1:=ActiveWorkbook.Path & "\" & strDate & " - " & "PPE" & " " & strDate1 &
" " & "T&A Worksheet", arg2:=1
ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
Application.Quit
ThisWorkbook.Close SaveChanges:=True

End With
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default SaveAs

Hi,

Try this:
' Please change this line
If
Application.Dialogs(xlDialogSaveAs).Show(arg1:=Act iveWorkbook.Path & _
"\" & strDate & " - " & "PPE" & " " & strDate1 & " " & "T&A
Worksheet", arg2:=1) = True Then
ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
Application.Quit
ThisWorkbook.Close SaveChanges:=True
End If

*** Cancel button will return FALSE ***
--
Malik


"blerman" wrote:

I have created the following macro, which is supposed to save the file based
on values in specific cells and then exit Excel, but it needs to be modified
to not save the file if the users clicks on the cancel button in the SaveAs
dialog box. I am a novice when it comes to this so any assistance with
specific examples will be greatly appreciated.

Sub saveexit()
'
' saveexit1 Macro
' Macro recorded 03/31/2008 by Barry Lerman
'
'
With ActiveWindow
strDate = Range("d2")
strDate1 = Format(Range("L2"), "mm-dd-yy")
Application.Dialogs(xlDialogSaveAs).Show _
arg1:=ActiveWorkbook.Path & "\" & strDate & " - " & "PPE" & " " & strDate1 &
" " & "T&A Worksheet", arg2:=1
ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
Application.Quit
ThisWorkbook.Close SaveChanges:=True

End With
End Sub

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

When it copied this code I receive a compile syntax error. Any suggestions?

"blerman" wrote:

I have created the following macro, which is supposed to save the file based
on values in specific cells and then exit Excel, but it needs to be modified
to not save the file if the users clicks on the cancel button in the SaveAs
dialog box. I am a novice when it comes to this so any assistance with
specific examples will be greatly appreciated.

Sub saveexit()
'
' saveexit1 Macro
' Macro recorded 03/31/2008 by Barry Lerman
'
'
With ActiveWindow
strDate = Range("d2")
strDate1 = Format(Range("L2"), "mm-dd-yy")
Application.Dialogs(xlDialogSaveAs).Show _
arg1:=ActiveWorkbook.Path & "\" & strDate & " - " & "PPE" & " " & strDate1 &
" " & "T&A Worksheet", arg2:=1
ActiveWorkbook.RunAutoMacros Which:=xlAutoClose
Application.Quit
ThisWorkbook.Close SaveChanges:=True

End With
End Sub

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
Using the SaveAs in VBA caldog Excel Programming 2 October 5th 05 01:05 AM
Help with SaveAs Glen Mettler[_4_] Excel Programming 2 March 4th 05 03:33 PM
SaveAs Bill[_19_] Excel Programming 1 January 27th 04 11:11 PM
SaveAs,csv popo pop Excel Programming 2 October 31st 03 06:08 AM
saveas Nikita Excel Programming 1 September 17th 03 02:39 AM


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