#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Save As

I am trying to set up a macro in a workbook so that when I run the macro the
file will Save As and prompt for a new file name. I would like to have the
old file name show in the box as I only need to change a few caracters.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Save As

I also need to switch back and forth between two workbooks with this same
macro. After I have specified the file name is there any way that the rest
of the macro will be able to call the workbook with the new name.

"kdreyer" wrote:

I am trying to set up a macro in a workbook so that when I run the macro the
file will Save As and prompt for a new file name. I would like to have the
old file name show in the box as I only need to change a few caracters.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Save As

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)

Dim filesavename as Variant
filesavename = Application.GetSaveAsFilename( _
ThisWorkbook.Filename, _
fileFilter:="Microsoft Excel Workbook (*.xls),*.xls")

If filesavename < False Then
Application.EnableEvents = False
if lcase(thisworkbook.fullname) = lcase(filesavename) then
thisworkbook.Save
else
on Error resume Next
kill filesavename
on Error goto 0
thisworkbook.SaveAs filesavename
end if
End If
Application.EnableEvents = True
Cancel = True
end sub

Put this in the ThisWorkbook module of each workbook.

In you code refer to the book containing the code as thisworkbook, and you
won't need the name.

for the workbook with the focus, use ActiveWorkbook.

--
Regards,
Tom Ogilvy


"kdreyer" wrote in message
...
I also need to switch back and forth between two workbooks with this same
macro. After I have specified the file name is there any way that the

rest
of the macro will be able to call the workbook with the new name.

"kdreyer" wrote:

I am trying to set up a macro in a workbook so that when I run the macro

the
file will Save As and prompt for a new file name. I would like to have

the
old file name show in the box as I only need to change a few caracters.



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
Save, save as, page setup dimmed out in unprotected excel sheet? ccKeithJ Excel Discussion (Misc queries) 3 December 14th 07 07:07 PM
Save As and save current numbers not the actual formulas and links Frank Menard Excel Discussion (Misc queries) 2 November 9th 06 09:18 PM
Command Button Save As Application.ExecuteExcel4Macro ("SAVE.AS?() Paul Dennis Excel Discussion (Misc queries) 5 September 18th 06 05:34 PM
when i save xls file, debug script is running and canno't save fil Imtiaz Excel Discussion (Misc queries) 1 July 16th 05 03:47 PM
Save As - Multiple Sheets fails to save as text file Ravee Srinivasan Excel Programming 2 November 10th 03 04:05 PM


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