Returning a file path

A

Adrian

Hi all,

Can anyone help with some code?

I have created a userform that has a command button that I
want to act as a browse button to gain the file path to
the users prefered picture. This file will then be later
added to a word 2000 doc.

Can anyone help me get started. I jsut cannot seem to even
start figuring it out.
I have gor as far as assuming that I will need the Dialogs
(wdDialogFileOpen). Show statement. But actually
retrieving the resulting file and file path is beyond me.

Many thanks
Adrian
 
J

Jean-Guy Marcil

Hi Adrian,

Right about the Dialogs, but maybe wrong about which one!

Try this (Thanks Doug!):

'_______________________________________
Dim PicFile as string

With Dialogs(wdDialogInsertPicture)
If .Display Then
PicFile = WordBasic.FilenameInfo$(.Name, 1)
End If
End With
'_______________________________________

The above code will display the Insert Picture dialog and the path\filename
of the selected picture will be loaded into the variable PicFile.


--
Cheers!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jay Freedman

Hi, Adrian,

See the snippet of code under the FileNameInfo$() heading in the
article at http://word.mvps.org/faqs/macrosvba/WordBasicCommands.htm.
It does exactly what you want.

Note that the code uses the dialog's .Display method and not the .Show
method. The difference is that .Show will actually open the selected
file, which you don't want in a browse dialog. The .Display will put
the dialog on screen and collect the user's choice, but won't actually
open the selected file.
 

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