Retrieving the value from a dialog

D

DevalilaJohn

I need to capture the full path and name for a file selected from the file
open dialog. I can get the dialog to display via the Dispaly option to
Dialogs(wdDialogFileOpen) and determine that the user hit OK, but how/where
do I find the data on the file selected?

Thanks for you assistance.

John
 
G

Greg Maxey

John,

I once found something similiar on the Word MVP site, but don't
remember where:

Sub ScratchMacro()
With Dialogs(wdDialogFileOpen)
If .Display <> 0 Then
MsgBox WordBasic.FilenameInfo(.Name, 1)
Else
MsgBox "No file selected"
End If
End With
End Sub
 
J

JBark

Greg,
How can I adjust this code so that it writes the path name to a textbox
field in a doc or form instead of a msgBox?
 
J

JBark

In case anyone else is wondering the same thing, here it is:
This is a button which calls the file open dialog and then writes the path
to a text box

Private Sub CommandButton1_Click()
With Dialogs(wdDialogFileOpen)
If .Display <> 0 Then
AttachedFile1.Text = WordBasic.FilenameInfo(.Name, 1)
Else
MsgBox "No file selected"
End If
End With
End Sub
 

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