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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paste Picture not available in VBA (Word 2002) any ideas

Status
Not open for further replies.

cresbydotcom

Technical User
May 22, 2006
234
thread68-1128047
I have (OK - shouldn't have) been pasting "by default" and wanted to change this to pasting as a picture and find "record macro" defaults to 'wdDefault' and looking in the Object Browser can't see a wd-BlahBlah that amounts to "paste as picture" directive. I can do it all by hand but was trying to automate a few things to simplify brain fade / boredom / &/or finger trouble in a large document for a very pedantic customer.

An alternative might be to convert every "Picture" to the more economical storage format but can't see how to - any ideas on solving either way?
 

I'm not entirely clear what you are doing but the same options available in Paste Special should be available to the PasteSpecial Method (wdPasteBitmap or wdPasteEnhancedMetaFile is probably what you want). Precisely what options are available depends entirely on the application you copy or cut from.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

Professional Office Developers Association
 
Yea for a manual "paste special" they are all there, record macro reports no error if you "paste picture" (fast and small it offers in the blurb)

but what it records and subsequently does as a macro is:

Selection.PasteAndFormat (wdPasteDefault)

the "wdDefault" is the only VBA attribute/variable that seems to apply to "Paste Special" and clearly is nothing special.

I just wondered if this is a Micro$oft "added feature" or just a drop-off.

Either way it can't be done by recording a macro and I can only see the manual approach unless someone else has come across this and found a work-around. Manual is hardly a macro unless I switch my brain off ................... which may be the prevailing condition.
 

It is possible that the macro recorder is giving you the wrong thing - sometimes it does :) - but

> Selection.PasteAndFormat (wdPasteDefault)

is not PasteSpecial.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

Professional Office Developers Association
 
Yea that's where I came in - the recorder defaults to wdPasteDefault. My guess is that Micro$oft found an error in that area and re-defined it as a feature! PasteSpecial - surely he means "paste ordinary".

The Object Browser does - eventually reveal a wdPasteMetafilePicture. and a few other things to try - so I will return when I have tried a few

Thanks for focussing the thinking though.
 
No I tried Selection.PasteSpecial (wdPasteDeviceIndependentBitmap)

also with
wdPasteEnhancedMetafile

and the most likely wdPasteMetafilePicture

all appear to work but the result is not the picture paste you get with manual paste special - and without properties to go at (I have looked and looked but............) the look of the result is my only clue - other than file size. It don't look the same therefore it ain't.
 
looks like this works so I may prat around with it as the core of a loop and maybe remove the collapse bit.

Sub pastepic()
Selection.Collapse Direction:=wdCollapseStart
Selection.Range.PasteSpecial DataType:=wdPasteMetafilePicture
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top