Discussion:
problem in inserting image
(too old to reply)
vj5
2006-07-13 11:50:01 UTC
Permalink
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
2006-07-13 12:33:43 UTC
Permalink
I don't follow you. But, can you make the image an AutoText entry?
--
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.
Post by vj5
hi experts
how to insert a image into word document from a resource file.
i can't give physical path of the file.
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?
vj5
2006-07-13 12:52:01 UTC
Permalink
no i can't make
Post by Charles Kenyon
I don't follow you. But, can you make the image an AutoText entry?
--
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.
Post by vj5
hi experts
how to insert a image into word document from a resource file.
i can't give physical path of the file.
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?
Jonathan West
2006-07-13 12:57:06 UTC
Permalink
Post by vj5
hi experts
how to insert a image into word document from a resource file.
i can't give physical path of the file.
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?
You'll need to extract it from the resource file first, maybe to a temporary
folder, and then insert it from there using AddPicture
--
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
2006-07-13 13:36:02 UTC
Permalink
but i can't save image at physical location. is there any other way to insert
the image?
Post by Jonathan West
Post by vj5
hi experts
how to insert a image into word document from a resource file.
i can't give physical path of the file.
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?
You'll need to extract it from the resource file first, maybe to a temporary
folder, and then insert it from there using AddPicture
--
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
Jonathan West
2006-07-13 15:25:12 UTC
Permalink
Post by vj5
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.
--
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
2006-07-14 05:09:01 UTC
Permalink
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?
Post by Jonathan West
Post by vj5
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.
--
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
Jonathan West
2006-07-14 08:02:53 UTC
Permalink
Post by vj5
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?
--
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
2006-07-17 05:03:01 UTC
Permalink
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?
Post by Jonathan West
Post by vj5
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?
--
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
Peter Karlström
2006-09-19 13:55:02 UTC
Permalink
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
--
Peter Karlström
Midrange AB
Sweden
Post by Jonathan West
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?
Post by Jonathan West
Post by vj5
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?
--
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
Loading...