My friend says that he cannot get the FileDialog Property in Word 2000.
i.e.
[VBA]
Dim Something as FileDialog
[/VBA]
I have only got Word 2003, and have no access to Word 2000. Is he telling the truth?
My friend says that he cannot get the FileDialog Property in Word 2000.
i.e.
[VBA]
Dim Something as FileDialog
[/VBA]
I have only got Word 2003, and have no access to Word 2000. Is he telling the truth?
Hi Samuel,
He's correct. In Word there's no FileDialog
In Word 2000 you can use:
[VBA] With Dialogs(wdDialogFileOpen)
..some code here
[/VBA]
Marcster.
Hi Marcster
I have the following code (written for Word 2003, and it works). how do I modify it using your suggestion?
[VBA]
Private Sub okButton_click()
Dim dlgSaveAs As FileDialog ' the offending line in Word 2000!!!
Dim Path As String
Path = ActiveDocument.Path
If Path = "" Then
Path = Options.DefaultFilePath(wdDocumentsPath)
End If
Path = Path + "\"
If ValidFileName Then ' i.e. the file path name contains no illegal characters
'Save file with new extension
Set dlgSaveAs = Application.FileDialog(FileDialogType:=msoFileDialogSaveAs)
dlgSaveAs.InitialFileName = Path + Trim(FileName) + ".doc"
dlgSaveAs.Show
dlgSaveAs.Execute
Unload SubjectNameForm
Else
MsgBox ("Invalid Filename - the characters / \ : * "" < > | $ & ' ` ? are not _
allowed in a Filename"), vbCritical
End If
End Sub
[/VBA]
In Word 2000 you display the SaveAsDialog like this:
[VBA]
With Dialogs(wdDialogFileSaveAs)
.Name = Path
.Show
End With
[/VBA]
But I can't see a way to get the (Path + Trim(FileName) + ".doc") in the filename box.
There's this, which saves the Doc:
[VBA]
ActiveDocument.SaveAs FileName:=Path + Trim(FileName) + ".doc"
[/VBA]
But that doesn't show the SaveAs Dialog.
Do you need to display the SaveAs Dialog?.
Marcster.
Hi Marcster
Basically, here is what I want this to do in 2000 as well as 2003:
A Userform is loaded when the user clicks a button. This form produces a string in a text box called FileName. When the user does okbutton_click() on the userform, I want to transfer that string to the Save As dialog box in the Save As window.
Does that explain things or have I got the wrong idea?
sam
Hey Marcster,
Never mind just been playing around, think I get you now!!! This seems to work for 2003, does it work for 2000?
[VBA]
Private Sub okButton_click()
Dim Path As String
Path = ActiveDocument.Path
If Path = "" Then
Path = Options.DefaultFilePath(wdDocumentsPath)
End If
Path = Path + "\"
If ValidFileName Then 'i.e. the file path name contains no illegal characters
With Dialogs(wdDialogFileSaveAs)
.Name = Path & Trim(FileName) & ".doc"
.Show
End With
Else
MsgBox ("Invalid Filename - the characters / \ : * "" < > | $ & ' ` ? are not allowed in a Filename"), vbCritical
End If
End Sub[/VBA]
Much obliged
I'll just check...
Marcster.
I've ran the code...
FileName, used on this line :
[VBA]
.Name = Path & Trim(FileName) & ".doc"
[/VBA]
is not defined in your code.
Fix:
[VBA]
Dim FileName As String
FileName = 'Name of file here'
[/VBA]
Once the above has been inserted, yep,
shows the SaveAs dialog.
In the dialog the File name box displays
the contents of FileName.
Marcster.
Ah, sorry, should have mentioned, FileName is a string output from the userform that this procedure is embedded in... Cheers Marcster!!
Thats OK then.
Glad I could help.
Marcster.