Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Save As Code

JT,

You may need more sophisticated error checking: does the file already exist, etc. but this will give
you an idea of where to start.

HTH,
Bernie
MS Excel MVP


Sub SaveFileWithUsersFileName()

Dim newFName As String

newFName = Application.GetSaveAsFilename

If newFName = "False" Then
MsgBox "You pressed cancel"
Exit Sub
End If

If InStr(1, newFName, ".xls") = 0 Then
newFName = newFName & ".xls"
End If

ActiveWorkbook.SaveAs Filename:=newFName, FileFormat:=xlNormal

End Sub


"JT" wrote in message
...
In my macro, I want to activate a certain workbook; which is no problem.

Workbooks(vOldFileName).Activate

What I want to do next is to open the save as dialog box and let the user
select a name for the "new file". Once they they have clicked the "save"
button, I will capture the active workbook name.

vNewFile = activeworkbook.name

I'm having trouble with the save as. Below is the code, I got when I
recorded a macro to use save as. The problem is I don't know what the user
will name the new file and the info below is what I called it when I recorded
the macro.

ActiveWorkbook.SaveAs Filename:="C:\Test\2007.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False

Any help with the code to display the save as dialog box, would be greatly
appreciated. Thanks for the help....

--
JT



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
Before Save code Kelly Excel Worksheet Functions 4 January 30th 08 03:57 PM
How to save my VBA-code Heine Excel Worksheet Functions 4 September 26th 06 05:46 PM
Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use: harpscardiff[_10_] Excel Programming 8 November 10th 05 12:24 PM
Placing a code before Save & Save As Alex Martinez Excel Programming 1 September 27th 05 06:35 AM
Save without VBA code? Joel Excel Programming 1 June 7th 05 05:15 PM


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