ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Prompt user for a filename (https://www.excelbanter.com/excel-programming/327116-prompt-user-filename.html)

J S

Prompt user for a filename
 
I want to create an excel macro that display the saveas dialog box to the
user, how do I do that?

i.e. I want the user to save the current document, but when I use
thisworkbook.save or thisworkbook.saveas excel does NOT display the saveas
dialog box where the user can select the filename and directory he wants to
save to.

-J



Edwin Tam[_7_]

Prompt user for a filename
 
You can use the GetSaveAsFilename method. An example is shown below. For more
information, you can search for the topic "GetSaveAsFilename method" in the
VBA online help.

Sub obtain_filename()
Dim fileSaveName As String
fileSaveName = Application.GetSaveAsFilename( _
InitialFileName:="MyFile", FileFilter:="Text Files (*.txt), *.txt")
If fileSaveName < False Then
MsgBox "Save as " & fileSaveName
End If
End Sub

Regards,
Edwin Tam

http://www.vonixx.com





"J S" wrote:

I want to create an excel macro that display the saveas dialog box to the
user, how do I do that?

i.e. I want the user to save the current document, but when I use
thisworkbook.save or thisworkbook.saveas excel does NOT display the saveas
dialog box where the user can select the filename and directory he wants to
save to.

-J




Jim Thomlinson[_3_]

Prompt user for a filename
 
Application.Dialogs(xlDialogSaveAs).Show "C:\Myfile.xls"

HTH

"J S" wrote:

I want to create an excel macro that display the saveas dialog box to the
user, how do I do that?

i.e. I want the user to save the current document, but when I use
thisworkbook.save or thisworkbook.saveas excel does NOT display the saveas
dialog box where the user can select the filename and directory he wants to
save to.

-J




Hans Petter

Prompt user for a filename
 
Use the GetSaveAsFilename method.
From Excel Helpfile:
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="Text Files (*.txt), *.txt")
If fileSaveName < False Then
MsgBox "Save as " & fileSaveName
End If

Then you can use the SaveAs method to save the fileSaveName

Hans Petter


"J S" skrev i melding ...
I want to create an excel macro that display the saveas dialog box to the
user, how do I do that?

i.e. I want the user to save the current document, but when I use
thisworkbook.save or thisworkbook.saveas excel does NOT display the saveas
dialog box where the user can select the filename and directory he wants

to
save to.

-J






All times are GMT +1. The time now is 08:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com