LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Help with altering a SaveAs macro . . .

Dave Peterson gave me a macro to save a workbook and it works great (much
thanks Dave!). But I now realize I need it to suggest a copy name for the
active workbook and then return to the active workbook after saving, not the
copy. I still want all the functionality that Dave's Macro gives, . . . but I
don't want my users saving over the original file by mistake.

For example, the active workbook is named: "PFSNov.xls" The macro would
suggest or pre-load the name "PFSNov_Copy.xls" save the workbook to a place
the user specifies, but return to "PFSNov.xls" after saving.

Dave's macro is as follows:

Option Explicit
Sub testme01()
Dim myFileName As Variant
Dim OkToSave As Boolean
Dim resp As Long

Do
myFileName = Application.GetSaveAsFilename _
(filefilter:="Excel files, *.xls")
If myFileName = False Then
Exit Sub
End If

OkToSave = True
If Dir(myFileName) = "" Then
'do nothing special
Else
resp = MsgBox(prompt:="Overwrite Existing file?", _
Buttons:=vbYesNoCancel)
Select Case resp
Case Is = vbCancel
MsgBox "Try again later"
Exit Sub
Case Is = vbNo
OkToSave = False
End Select
End If

If OkToSave Then
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=myFileName, _
FileFormat:=xlWorkbookNormal
Application.DisplayAlerts = True
Exit Do
End If
Loop

End Sub

I've tried playing around and modifying it, but being very new to this, all
I get is a variety of different error messages. Any ideas?

WillRn
 
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 in Macro gfkbob[_2_] Excel Discussion (Misc queries) 2 April 12th 07 10:52 PM
SaveAS macro Query Nigel Excel Discussion (Misc queries) 1 May 13th 05 01:17 PM
Saveas Macro Nigel Excel Discussion (Misc queries) 3 May 11th 05 01:15 PM
Help with SaveAs Macro on Auto_Open Daen Excel Programming 3 September 15th 04 11:08 PM
SaveAs Macro Help? NeuralNetwork Excel Programming 4 December 23rd 03 04:17 PM


All times are GMT +1. The time now is 02:25 AM.

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"