issue with filedialog browser

A

Associates

Hi,

I have a question. I've a userform that has a textfield. Next to it, there
is a button with caption "Browse". I was thinking that when user wants to
insert a picture, he/she clicks on "browse" that will bring up a filedialog
box for user to select which image file they want to insert to the document.
Once, they have chosen the file, the filepath will be captured and shown in
the textfield that is next to it. After user has filled out all the text
fields in the userform and press "ok" button, all the user data will be
dumped to the word document. I use bookmark to do this.

So, getting back to my question. i have a bookmark in the word document. I
was hoping, the image will be placed where the bookmark for the image is in
the word document.

I use the following code to bring up the filedialog but couldn't retrieve
the filepath to the textfield. Instead, it actually opens up the file.
Dialogs(wdDialogFileOpen).Show

I have tried to use the following codes
Dim dlgOpen As FileDialog
Set dlgOpen = Application.FileDialog( _
FileDialogType:=msoFileDialogOpen)

but got error message saying "invalid property".

I have done this before in excel but the codes below doesn't work well with
word.
filein = Application.GetOpenFilename()

Your help would be greatly appreciated.

Thank you in advance
 
D

Doug Robbins - Word MVP

The following code displays the Insert Picture dialog and then inserts the
path\filename for the selected picture into a textbox txtPicturePath on the
user form:

' Display the InsertPicture dialog
With Dialogs(wdDialogInsertPicture)
If .Display Then
'Populate the txtPicturePath control with the selected filename
txtPicturePath = WordBasic.FilenameInfo$(.Name, 1)
End If
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Jonathan West

Which version of Office are you using? If I recall, the FileDialog object
isn't available in Office 2000, but was introduced in Office XP.
 

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