Populate ImageBox Control on a VB Form 
Author Message
 Populate ImageBox Control on a VB Form

I want to know if there is a way to extract a picture from
a Word document and populate the imagebox control on a VB
form without having to hard code the path of the graphic
file.  Then, I want to use VB code to take, or change, the
picture loaded in the imagebox control and re-insert it
into the Word document.

The following is the VB code I have been working with.  It
only works if I hard code the path of the graphic file:

'Populate the imagebox control as soon as the form is
executed
imgCoLogo.Picture = LoadPicture("C:\Logos\logo.jpg")

'Extracting a picture from an imagebox control in a
UserForm
SavePicture imgCoLogo.Picture, "C:\Logos\logo.jpg"

Simply put, I want to use VB code to pick up a "variable"
picture in the Word document and populate the picture in
the imagebox control.  Then, I could change the picture in
the imagebox control, and insert it back into the
document.  I guess I'm looking for some VB code that could
deal with variables rather than having to explicitly state
the path of the graphic file in parentheses as shown above
in my code.

Thanks for your help on this.

Simon    



Sat, 18 Sep 2004 09:51:09 GMT  
 Populate ImageBox Control on a VB Form
Hi Simon,

I'd say you should address this question to a VB group, not a
Word group, in this case.

<<Simply put, I want to use VB code to pick up a "variable"
picture in the Word document and populate the picture in
the imagebox control.  Then, I could change the picture in
the imagebox control, and insert it back into the
document.  I guess I'm looking for some VB code that could
deal with variables rather than having to explicitly state
the path of the graphic file in parentheses as shown above
in my code.>>

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :-)



Sat, 18 Sep 2004 21:05:03 GMT  
 Populate ImageBox Control on a VB Form
Hi Simon,

---I want to use VB code to pick up a "variable" picture in the Word
document and populate the picture in the imagebox control----
You can do this if you insert the pictures in the Word document as
{INCLUDEPICTURE} fields. If you turn on View Field Codes, then you will see
something like

{INCLUDEPICTURE "D:\\Graphics\\Gif\\AbortWarning.gif" \* MERGEFORMAT \d}
or
{INCLUDEPICTURE "D:\\Graphics\\Gif\\AbortWarning.gif" \* MERGEFORMAT }

In Word, you'd either bookmark this field or know its index position (as the
following example shows) so that you can reference it.

sImage = Replace(ActiveDocument.Fields(1).Code, " INCLUDEPICTURE", "")
sImage = Replace(sImage, " \* MERGEFORMAT \d ", "")
'Populate the imagebox control as soon as the form is
' executed
imgCoLogo.Picture = LoadPicture(sImage)

'Extracting a picture from an imagebox control in a
' UserForm
SavePicture imgCoLogo.Picture, sImage

HTH


Quote:
> I want to know if there is a way to extract a picture from
> a Word document and populate the imagebox control on a VB
> form without having to hard code the path of the graphic
> file.  Then, I want to use VB code to take, or change, the
> picture loaded in the imagebox control and re-insert it
> into the Word document.

> The following is the VB code I have been working with.  It
> only works if I hard code the path of the graphic file:

> 'Populate the imagebox control as soon as the form is
> executed
> imgCoLogo.Picture = LoadPicture("C:\Logos\logo.jpg")

> 'Extracting a picture from an imagebox control in a
> UserForm
> SavePicture imgCoLogo.Picture, "C:\Logos\logo.jpg"

> Simply put, I want to use VB code to pick up a "variable"
> picture in the Word document and populate the picture in
> the imagebox control.  Then, I could change the picture in
> the imagebox control, and insert it back into the
> document.  I guess I'm looking for some VB code that could
> deal with variables rather than having to explicitly state
> the path of the graphic file in parentheses as shown above
> in my code.

> Thanks for your help on this.

> Simon



Sat, 18 Sep 2004 21:26:37 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Taking Pictures from Word and Populating Imageboxes in a Userform

2. IMAGEbox dropped onto another imagebox flakey

3. DataGrid ComboBox control populate form

4. Populating form with my activeX control @ run time

5. Populating 3 fields in Combobox in VB.Net Windows Forms

6. ImageBox Control - File Formats.

7. reverse populate from Access2000 to VB/ADO form

8. Record select in popup form to populate parent form

9. Populating form with input from another form

10. trying to populate treeview control in activex using vb script

11. How to acess forms controls of one form from other in VB.NET

12. Controlling events on an Access Form from a VB form

 

 
Powered by phpBB® Forum Software