Paste a bitmap from VB.NET2005 to Word2000

J

Jiao

I am trying to paste an image in a pictureBox in vb.NET to a Word document.
When using the paste method, the image quality in Word is bad. If using
pasteSpecial method, all the dataType, like wdPasteBitmap or
wdPasteEnhancedMetafile, etc. are not available.

The code is as follows:
wdApp = CreateObject("Word.Application")
wordD = wdApp.Documents.Add
My.Computer.Clipboard.Clear()
My.Computer.Clipboard.SetImage(bm)
wordD.Sections.Item(1).Range.PasteSpecial(Link:=False,
DataType:=Word.WdPasteDataType.wdPasteShape)

Does Anyone know how?

I also find that when using pasteSpecial to paste a picture to Word, the
foramt of JPeg, Png, etc are not available until you cut the pasted picture
and do the pastSpecial again.

Thanks.
 
J

Jezebel

The DataType can be any of the wdPasteSpecial values supported by the
graphic you've copied. If JPG, PNG, etc aren't available, it's because those
formats aren't present in the clipboard at the time. Word has no control
over what happens when you do the SetImage from another source. When you
copy FROM Word, Word puts the image into the clipboard in a lot of different
formats -- hence the range of options if you then paste back.

In general, a better way to put images into a document is via a separate
file: then you have complete control over the format, and Word doesn't get
an opportunity to screw around with the image either.
 
Top