calling up Save / Save As from a userform

R

Roger on Excel

Is there code to allow one to call up the Save/SaveAs dialog boxes using
command buttons on a userform?

Thanks in advance,

Roger
 
M

marcus

Hi Roger

Use this for bringing up the Saveas dialog box. Attach it to your
code for a commmand button.

Take care

Marcus

Application.Dialogs(xlDialogSaveAs).Show
 
M

Matthew Herbert

Roger,

The GetSaveAsFilename method should do the trick. You can embed the code in
the command button click event. The help documentation on GetSaveAsFilename
is good, so search the help from VBE for GetSaveAsFilename.

A side note to GetSaveAsFilename is that the method doesn't actually save
anything, so you'll have to do some input validation in addition to an actual
save operation (i.e. the Save method). For example, GetSaveAsFilename
returns a Variant. The two Variant return types (that I'm aware of) are
Boolean and String. The method returns "False" if the dialog box is
canceled, or it returns the fully qualified file name (i.e. the directory
hierarchy, file name, and file extension) of a valid input. You can test the
type of data returned using the TypeName function. Also, the method doesn't
perform an actual save operation, so you'll have to us the Save method if you
plan on needing to save the file.

Best,

Matthew Herbert

Dim varRes as Variant
varRes = Application.GetSaveAsFilename(....'etc.
If TypeName(varRes) = "Boolean" Then
'etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top