Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Macro?

Status
Not open for further replies.

CRHamilton

Technical User
Jul 21, 2003
6
0
0
US
I am trying to setup a macro in Excel 2k that will initiate the SaveAs function, but will stop and prompt for a file name. Trying to use the "Record a Macro" in excel, then go into the VBS editor, but nothing seems to work. Can anyone point me in the right direction? Thnx in advance for any assistance!
 
Use the ShowSave Command.

object.ShowSave

This should open the SaveAs dialog box.

Hope this helps!

Jon
 
Hmmm... guess I am not getting it... Here is the script from the recording:

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 12/11/2003 by CRHamilton
'
' Keyboard Shortcut: Ctrl+z
'
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\crhamilton\Desktop\Book1.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
End Sub

Where would I put the object.ShowSave?

Thnx!
 
This is how it should look:

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 12/11/2003 by CRHamilton
'
' Keyboard Shortcut: Ctrl+z
'
ActiveWorkbook.ShowSave

End Sub

Hope this helps!

Jon
 
I get an Run-time error '438'

Object doesn't support this property or method.

Any idea what I'm doing wrong? (cut and pasted it into the editor, replacing what was already there.)
 
Yeah, my fault. ShowSave is a CommonDialog method. That is, you have to have CommonDialog controls. Then you would have the following line of code:

CommonDialog1.ShowSave

Sorry about the confusion.

Jon
 
Hi,

Use the GetOpenFilename method to get the name of the file to save as...
Code:
fileToOpen = Application _
    .GetOpenFilename("Excel Files (*.xls), *.xls")
If fileToOpen <> False Then
    MsgBox &quot;Open &quot; & fileToOpen
End If
:)

Skip,
 
Hmmm... this doesn't prompt me to save the file, but rather gives me the Open box to selct the file to open... am I missing something here? :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top