Group:  Microsoft Word » microsoft.public.word.vba.addins
Thread: problem in inserting image

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

problem in inserting image
vj5 13.07.2006 11:50:01
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?


Re: problem in inserting image
"Charles Kenyon" <wordfaq[ at ]nospam.addbalance.com> 13.07.2006 12:33:43
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.


"vj5" <vj5[ at ]discussions.microsoft.com> wrote in message
news:5069AB02-0330-40FA-8774-A36E2462378E[ at ]microsoft.com...
[Quoted Text]
> 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?
>
>


Re: problem in inserting image
vj5 13.07.2006 12:52:01
no i can't make

"Charles Kenyon" wrote:

[Quoted Text]
> 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.
>
>
> "vj5" <vj5[ at ]discussions.microsoft.com> wrote in message
> news:5069AB02-0330-40FA-8774-A36E2462378E[ at ]microsoft.com...
> > 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?
> >
> >
>
>
>
Re: problem in inserting image
"Jonathan West" <jwest[ at ]mvps.org> 13.07.2006 12:57:06

"vj5" <vj5[ at ]discussions.microsoft.com> wrote in message
news:5069AB02-0330-40FA-8774-A36E2462378E[ at ]microsoft.com...
[Quoted Text]
> 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?
>
>

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

Re: problem in inserting image
vj5 13.07.2006 13:36:02
but i can't save image at physical location. is there any other way to insert
the image?

"Jonathan West" wrote:

[Quoted Text]
>
> "vj5" <vj5[ at ]discussions.microsoft.com> wrote in message
> news:5069AB02-0330-40FA-8774-A36E2462378E[ at ]microsoft.com...
> > 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?
> >
> >
>
> 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
>
>
Re: problem in inserting image
"Jonathan West" <jwest[ at ]mvps.org> 13.07.2006 15:25:12

"vj5" <vj5[ at ]discussions.microsoft.com> wrote in message
news:978D4057-6A6C-4A92-B7E5-B2F0794D783B[ at ]microsoft.com...
[Quoted Text]
> 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

Re: problem in inserting image
vj5 14.07.2006 05:09:01
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?


"Jonathan West" wrote:

[Quoted Text]
>
> "vj5" <vj5[ at ]discussions.microsoft.com> wrote in message
> news:978D4057-6A6C-4A92-B7E5-B2F0794D783B[ at ]microsoft.com...
> > 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
>
>
Re: problem in inserting image
"Jonathan West" <jwest[ at ]mvps.org> 14.07.2006 08:02:53

"vj5" <vj5[ at ]discussions.microsoft.com> wrote in message
news:CDE0D147-CCA5-425F-9A31-0958CE90C9EA[ at ]microsoft.com...
[Quoted Text]
> 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

Re: problem in inserting image
vj5 17.07.2006 05:03:01
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?

"Jonathan West" wrote:

[Quoted Text]
>
> "vj5" <vj5[ at ]discussions.microsoft.com> wrote in message
> news:CDE0D147-CCA5-425F-9A31-0958CE90C9EA[ at ]microsoft.com...
> > 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
>
>
Re: problem in inserting image
Peter Karlström 19.09.2006 13:55:02
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


"vj5" wrote:

[Quoted Text]
> 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?
>
> "Jonathan West" wrote:
>
> >
> > "vj5" <vj5[ at ]discussions.microsoft.com> wrote in message
> > news:CDE0D147-CCA5-425F-9A31-0958CE90C9EA[ at ]microsoft.com...
> > > 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
> >
> >

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net