[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Re: msoFileDialogSaveAs

Jim Rech

12/19/2006 9:45:00 PM

FYI, if your goal is to assist the user in saving the workbook I think most
developers use Application.GetSaveAsFilename. This gives you more control
as you can set a default name, check/modify the name and folder the user
selects, etc.

Sub SaveFile()
Dim FName As Variant
FName = Application.GetSaveAsFilename(, "Excel files (*.xls),*.xls")
If FName = False Then
MsgBox "User cancelled"
Else
ActiveWorkbook.SaveAs FName
End If
End Sub


--
Jim
"DKS" <DKS@discussions.microsoft.com> wrote in message
news:A61431D6-CF39-49C1-8570-E45520D4869A@microsoft.com...
|I have two questions on the usage of msoFileDialogSaveAs:
|
| (a) in the following code
| With Application.FileDialog(msoFileDialogSaveAs)
| .Show
| .Execute
| End With
|
| when the .execute method is run, a dialog box is saved where one can
browse
| to a folder and save the file. Nevertheless, the dialog box provides a
| CANCEL option also. How do I trap programatically if the user clicks on
| CANCEL button?
|
| (b) second question
|
| My .xls with a macro using the msoFileDialogSaveAs gives an error when run
| from the PC of my friends and colleagues. The error is on the .execute
| method where excel gives an error that the method cannot be applied (or
does
| not exist - I forgot the actual error message but can find out if somebody
| out there needs to know the exact error message).
|
| Any idea why this method works on my PC and not on other's PC with exactly
| same configuration (XP, Excel 2003). I thought that this could have to do
| something with Add-ins. I removed all add-ins from my PC (by simply
| deselecting add-ins via TOOLS, ADD-IN ...). After deselecting all add-ins
I
| re-ran the macro on my PC and it works fine. Thus it cannot be add-in (or
so
| I believe).
|
| All help appreciated.


1 Answer

DKS

12/20/2006 12:35:00 PM

0

Thanks for this tip. My goal indeed is to help the user select the folder
and file name for where to store the "active workbook".

Many thanks



"Jim Rech" wrote:

> FYI, if your goal is to assist the user in saving the workbook I think most
> developers use Application.GetSaveAsFilename. This gives you more control
> as you can set a default name, check/modify the name and folder the user
> selects, etc.
>
> Sub SaveFile()
> Dim FName As Variant
> FName = Application.GetSaveAsFilename(, "Excel files (*.xls),*.xls")
> If FName = False Then
> MsgBox "User cancelled"
> Else
> ActiveWorkbook.SaveAs FName
> End If
> End Sub
>
>
> --
> Jim
> "DKS" <DKS@discussions.microsoft.com> wrote in message
> news:A61431D6-CF39-49C1-8570-E45520D4869A@microsoft.com...
> |I have two questions on the usage of msoFileDialogSaveAs:
> |
> | (a) in the following code
> | With Application.FileDialog(msoFileDialogSaveAs)
> | .Show
> | .Execute
> | End With
> |
> | when the .execute method is run, a dialog box is saved where one can
> browse
> | to a folder and save the file. Nevertheless, the dialog box provides a
> | CANCEL option also. How do I trap programatically if the user clicks on
> | CANCEL button?
> |
> | (b) second question
> |
> | My .xls with a macro using the msoFileDialogSaveAs gives an error when run
> | from the PC of my friends and colleagues. The error is on the .execute
> | method where excel gives an error that the method cannot be applied (or
> does
> | not exist - I forgot the actual error message but can find out if somebody
> | out there needs to know the exact error message).
> |
> | Any idea why this method works on my PC and not on other's PC with exactly
> | same configuration (XP, Excel 2003). I thought that this could have to do
> | something with Add-ins. I removed all add-ins from my PC (by simply
> | deselecting add-ins via TOOLS, ADD-IN ...). After deselecting all add-ins
> I
> | re-ran the macro on my PC and it works fine. Thus it cannot be add-in (or
> so
> | I believe).
> |
> | All help appreciated.
>
>
>