PDA

View Full Version : Dialogs...



samuelwright
12-09-2005, 04:56 AM
Hi

In Word, I have a userform with a button that opens the Save as dialog box using the following code:


'Path is a string (Activedocument.path) and FileName is also a string that
'gets put into the File Name box using .Name

With Application.Dialogs(wdDialogFileSaveAs)
.Name = Path & Trim(FileName) & ".doc"
.Show
End With



However, when I try the same in Excel, it doesnt put the name into the file save box...in fact it gives an error. what is the difference and how can I make it work?


With Application.Dialogs(xlDialogSaveAs)
.Name = Path & Trim(FileName) & ".xls"
.Show


:dunno

Marcster
12-09-2005, 07:37 AM
Sam,

The .Name doesn't exist (unlike Word) in Dialog so Excel shows an error.
.Name = Path & Trim(Filename) & ".xls" 'Errors
You can save a file without showing a dialog:
ThisWorkbook.SaveAs Path & Trim(Filename) & ".xls"
or by showing the dialog you can retrieve the filename the user
has chosen:
strSavedFileName = Application.GetSaveAsFilename
Can't think of a way to show a custom file name in the SaveAs dialog.

Maybe someone more knowledgeable does know?...

Marcster.

samuelwright
12-09-2005, 08:35 AM
Hi Marcster

I tried this


Application.GetSaveAsFilename (FileName)


Where FileName is a string available from the user form. Guess what...it puts the FileName string in the Save As Dialog! Job done as far as Im concerned! Thank you very much!!

PS is GetSaveAsFileName available in mso9.dll? I have mso11.dll you see

Bob Phillips
12-09-2005, 08:38 AM
PS is GetSaveAsFileName available in mso9.dll? I have mso11.dll you see

Excel 9 - yes!

samuelwright
12-09-2005, 08:41 AM
Wonderful!! I love it when utter despair turns to elation, and its all down to VBAX, you guys rock!!:rockband:

Thank you so much,

ps I love the smilies, who did them??