Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word table paste/pastespecial into cell issue

Status
Not open for further replies.

baltman

Technical User
Mar 5, 2002
1,578
0
0
US
Hi all,

I am trying to pastespecial an image into a specific cell in a word table. When I use the simple paste it is placed into the correct cell but when I use pastespecial it always goes into the 1st column of the table.

I'm in Office 2013 and creating a chart in Excel and then trying to place it into the word table:

Works but I need an image:
oTbl.Cell(nTblCellRow, nTblCellCol).Range.Paste

Is an image but always in the 1st column of the word table regardless of the nTblCellCol value:
oTbl.Cell(nTblCellRow, nTblCellCol).Range.PasteSpecial Link:=False, DataType:=14, _
Placement:=0, DisplayAsIcon:=False

So What the heck can I do to get my desired outcome? Thank you!
 
I'd love to hear if there is a better solution but I defined a 1x1 working table in word and did the pastespecial there then I copied that result and did the normal paste into where I actually wanted it. At the end of the process I delete the working table.
 
Hi,

I don't see a 14 for DataType
[pre]
Name Value Description

wdPasteBitmap 4 Bitmap.
wdPasteDeviceIndependentBitmap 5 Device-independent bitmap.
wdPasteEnhancedMetafile 9 Enhanced metafile.
wdPasteHTML 10 HTML.
wdPasteHyperlink 7 Hyperlink.
wdPasteMetafilePicture 3 Metafile picture.
wdPasteOLEObject 0 OLE object.
wdPasteRTF 1 Rich Text Format (RTF).
wdPasteShape 8 Shape.
wdPasteText 2 Text.

[/pre]


Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
I don't see it documented either but it is recognized. Visually it looks identical to wdPasteShape. I can't remember where I got 14 from. 14 seems to be an image copy of wdPasteShape. The formatting of the graphs are retained when the document is later opened in Word 2010 but with wdPasteShape the formatting is lost.
 
Although DataType:=14 isn't listed, I don't get an error when using it with a suitable data type, but it does result in the object appearing in the wrong cell. Using undocumented 'features' is unreliable. Moreover, the image goes into the nominated table cell when using documented data types, such as:
oTbl.Cell(nTblCellRow, nTblCellCol).Range.PasteSpecial Link:=False, DataType:=3, Placement:=0, DisplayAsIcon:=False
or:
oTbl.Cell(nTblCellRow, nTblCellCol).Range.PasteSpecial Link:=False, DataType:=8, Placement:=0, DisplayAsIcon:=False


Cheers
Paul Edstein
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top