hi experts
how to insert a image into word document from a resource file.
i can't give physical path of the file.
at present i am using the code:
myapplication.Selection.InlineShapes.AddPicture("c:\myimage.bmp", ref
omissing,
ref omissing, ref omissing);
i wants to take image from resource file
is there any possiblity to do the same?
Charles Kenyon - 13 Jul 2006 13:33 GMT
I don't follow you. But, can you make the image an AutoText entry?

Signature
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
My criminal defense site: http://addbalance.com
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
> hi experts
> how to insert a image into word document from a resource file.
[quoted text clipped - 7 lines]
> i wants to take image from resource file
> is there any possiblity to do the same?
vj5 - 13 Jul 2006 13:52 GMT
no i can't make
> I don't follow you. But, can you make the image an AutoText entry?
> > hi experts
[quoted text clipped - 8 lines]
> > i wants to take image from resource file
> > is there any possiblity to do the same?
Jonathan West - 13 Jul 2006 13:57 GMT
> hi experts
> how to insert a image into word document from a resource file.
[quoted text clipped - 7 lines]
> i wants to take image from resource file
> is there any possiblity to do the same?
You'll need to extract it from the resource file first, maybe to a temporary
folder, and then insert it from there using AddPicture

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
vj5 - 13 Jul 2006 14:36 GMT
but i can't save image at physical location. is there any other way to insert
the image?
> > hi experts
> > how to insert a image into word document from a resource file.
[quoted text clipped - 10 lines]
> You'll need to extract it from the resource file first, maybe to a temporary
> folder, and then insert it from there using AddPicture
Jonathan West - 13 Jul 2006 16:25 GMT
> but i can't save image at physical location. is there any other way to
> insert
> the image?
Put it into the clipboard and use the Paste method to paste it into the
document.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
vj5 - 14 Jul 2006 06:09 GMT
but its going wrong when there is some text which is alraedy copied than it
will overwrite that text with image. how to solve this?
> > but i can't save image at physical location. is there any other way to
> > insert
> > the image?
>
> Put it into the clipboard and use the Paste method to paste it into the
> document.
Jonathan West - 14 Jul 2006 09:02 GMT
> but its going wrong when there is some text which is alraedy copied than
> it
> will overwrite that text with image. how to solve this?
Do you mean text in the clipboard or text in the document?

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
vj5 - 17 Jul 2006 06:03 GMT
text in the document
if there is some important data is copied by user on clipboard than it will
be replace by image. therefore copy on clipboard is not userfull.
is there any other method to do the same?
> > but its going wrong when there is some text which is alraedy copied than
> > it
> > will overwrite that text with image. how to solve this?
>
> Do you mean text in the clipboard or text in the document?
Peter Karlström - 19 Sep 2006 14:55 GMT
Hi
The clipboard is the only way, and your problem is easy to solve.
First read the contents of the clipboard and store this data in av variable.
Then copy your image to the clipboard and paste it to the document.
Then restore the contents of the clipboard from the variable.
I have two routines which I use:
First declare variables module-wide
Private clpPict As Picture 'Image from Clipboard
Private clpText As String 'Text from Clipboard
Private clpType As Integer 'Type of data in Clipboard
Sub SaveClip()
If Clipboard.GetFormat(vbCFText) Then
clpType = 1 'Text
clpText = Clipboard.GetText()
Exit Sub
End If
If Clipboard.GetFormat(vbCFBitmap) Then
Set clpPict = Clipboard.GetData(vbCFBitmap)
clpType = 2 'Image
Exit Sub
End If
If Clipboard.GetFormat(vbCFMetafile) Then
Set clpPict = Clipboard.GetData(vbCFMetafile)
clpType = 2 'Image
Exit Sub
End If
If Clipboard.GetFormat(vbCFDIB) Then
Set clpPict = Clipboard.GetData(vbCFDIB)
clpType = 2 'Image
Exit Sub
End If
If Clipboard.GetFormat(vbCFPalette) Then
Set clpPict = Clipboard.GetData(vbCFPalette)
clpType = 2 'Image
Exit Sub
End If
end sub
Private Sub GetClip(ByVal clipType As Integer)
'Restore Clipboard data
Select Case clipType
Case 1 'Text
Clipboard.SetText (clpText)
Case 2
Clipboard.SetData clpPict
Case Else
Clipboard.Clear
End Select
End Sub
Regards

Signature
Peter Karlström
Midrange AB
Sweden
> text in the document
> if there is some important data is copied by user on clipboard than it will
[quoted text clipped - 6 lines]
> >
> > Do you mean text in the clipboard or text in the document?