Image browser to insert pic

T

tyrin

Hi all, I'm trying to insert a picture into a word document using a browser window because the file name is always different and user specific. I have no idea what code to use or if it even exist, tried help but to no avail. Thank uou for any assistance in advance...
 
S

Steve Hudson

G'day "tyrin" <[email protected]>,

errr, I don't understand. If you were using VBA you wouldn't be using
the browser window?

tyrin said:
Hi all, I'm trying to insert a picture into a word document using a browser window because the file name is always different and user specific. I have no idea what code to use or if it even exist, tried help but to no avail. Thank uou for any assistance in advance...

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Tyrin,

Dim PicFile as string

With Dialogs(wdDialogInsertPicture)
If .Display Then
'Populate the txtLargeLogoPath control with the selected
filename
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.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
J

JGM

Hi Doug,

A quick question:

Why the
If End If
around the
.Display Then
PicFile = WordBasic.FilenameInfo$(.Name, 1)
lines?

It works just as well without... So, I am wondering if you could help me go
to bed less stupid tonight!

TIA
--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Jean Guy,

Try clicking the Cancel button in the dialog with and without the If End If
and I believe that you will sleep better tonight.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
J

JGM

Hi Doug,

Thanks... indeed I'll sleep better!

I see now why I missed that... I always give my user the option of
cancelling when I pop up dialog boxes. Oftentimes, that is when the user
realizes that he/she has forgotten something, (i.e. when they see the list
of files...). So I would use something like:

'_______________________________________
Dim PicFile As String

With Dialogs(wdDialogInsertPicture)
.Display
If Not .Name = "" Then
PicFile = .Name
Else
MsgBox "Action cancelled by user", vbExclamation, "Cancelled"
Exit Sub 'or other appropriate "undo" stuff...
End If
End With
'_______________________________________

to handle a user cancellation in this particular case.

Finally, a last question:
I see you use
WordBasic.FilenameInfo$(.Name, 1)

Is this because in previous versions of Word only the file name was
returned? Under XP, ".Name" returns the full path and file name...

Thanks again for your time.

--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Jean Guy,

Thanks for the "heads up" on the ability to merely use .Name in XP (and
2003) to get the File Path and Name. When VBA first appeared with Word97, I
don't think that was the case.

Now of course, if you just want to get the filename and the path (without
parsing the string), you need to use:

WordBasic.FilenameInfo$(.Name, 0)

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
J

JGM

Thanks Doug,

That good to know too! (I mean the bit with/without path using [
WordBasic.FilenameInfo$(.Name, 0) ] ).

Do you know if MS intends to keep Wordbasic commands compatible for ever? I
mean, aren't they one day decide that it was too archaic for, let say, Word
2005?

Thanks again.

--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
 
J

Jonathan West

JGM said:
Thanks Doug,

That good to know too! (I mean the bit with/without path using [
WordBasic.FilenameInfo$(.Name, 0) ] ).

Do you know if MS intends to keep Wordbasic commands compatible for ever? I
mean, aren't they one day decide that it was too archaic for, let say, Word
2005?

We have received no information on the subject. But if there were a
suggestion from Microsoft that the WordBasic object should be dropped, I
would oppose it for the reason that it does a number of things which can't
be done in VBA by any other means. Take a look here for some examples.

Useful WordBasic commands that have no VBA equivalent
http://www.mvps.org/word/FAQs/MacrosVBA/WordBasicCommands.htm
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Jean Guy,

I have found that in Word 2003, .Name only returns the filename, not the
path and the name. Back to WordBasic!

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
JGM said:
Thanks Doug,

That good to know too! (I mean the bit with/without path using [
WordBasic.FilenameInfo$(.Name, 0) ] ).

Do you know if MS intends to keep Wordbasic commands compatible for ever?
I
mean, aren't they one day decide that it was too archaic for, let say,
Word
2005?

Thanks again.

--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
Hi Jean Guy,

Thanks for the "heads up" on the ability to merely use .Name in XP (and
2003) to get the File Path and Name. When VBA first appeared with
Word97, I
don't think that was the case.

Now of course, if you just want to get the filename and the path (without
parsing the string), you need to use:

WordBasic.FilenameInfo$(.Name, 0)

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
J

JGM

Hi Doug,

Thanks for the info...
Why, oh why, does MS always have to mess with our heads like that?

Cheeers!

--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
Hi Jean Guy,

I have found that in Word 2003, .Name only returns the filename, not the
path and the name. Back to WordBasic!

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
JGM said:
Thanks Doug,

That good to know too! (I mean the bit with/without path using [
WordBasic.FilenameInfo$(.Name, 0) ] ).

Do you know if MS intends to keep Wordbasic commands compatible for ever?
I
mean, aren't they one day decide that it was too archaic for, let say,
Word
2005?

Thanks again.

--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
Hi Jean Guy,

Thanks for the "heads up" on the ability to merely use .Name in XP (and
2003) to get the File Path and Name. When VBA first appeared with
Word97, I
don't think that was the case.

Now of course, if you just want to get the filename and the path (without
parsing the string), you need to use:

WordBasic.FilenameInfo$(.Name, 0)

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
Hi Doug,

Thanks... indeed I'll sleep better!

I see now why I missed that... I always give my user the option of
cancelling when I pop up dialog boxes. Oftentimes, that is when the
user
realizes that he/she has forgotten something, (i.e. when they see the list
of files...). So I would use something like:

'_______________________________________
Dim PicFile As String

With Dialogs(wdDialogInsertPicture)
.Display
If Not .Name = "" Then
PicFile = .Name
Else
MsgBox "Action cancelled by user", vbExclamation,
"Cancelled"
Exit Sub 'or other appropriate "undo" stuff...
End If
End With
'_______________________________________

to handle a user cancellation in this particular case.

Finally, a last question:
I see you use
WordBasic.FilenameInfo$(.Name, 1)

Is this because in previous versions of Word only the file name was
returned? Under XP, ".Name" returns the full path and file name...

Thanks again for your time.

--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
<[email protected]> a écrit dans le message de #[email protected]...
Hi Jean Guy,

Try clicking the Cancel button in the dialog with and without the If End
If
and I believe that you will sleep better tonight.

--
Please post any further questions or followup to the newsgroups for
the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
Hi Doug,

A quick question:

Why the
If End If
around the
.Display Then
PicFile = WordBasic.FilenameInfo$(.Name, 1)
lines?

It works just as well without... So, I am wondering if you could
help
me
go
to bed less stupid tonight!

TIA
--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL
ADDRESS"
<[email protected]> a écrit dans le message de (e-mail address removed)...
Hi Tyrin,

Dim PicFile as string

With Dialogs(wdDialogInsertPicture)
If .Display Then
'Populate the txtLargeLogoPath control with the
selected
filename
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.

Please post any further questions or followup to the newsgroups for
the
benefit of others who may be interested. Unsolicited questions
forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
Hi all, I'm trying to insert a picture into a word document
using
a
browser window because the file name is always different and user
specific. I have no idea what code to use or if it even exist,
tried
help
but to no avail. Thank uou for any assistance in advance...
 

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