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

Problem with PasteAndFormat

Status
Not open for further replies.

DataHugger

Programmer
May 26, 2004
38
US
Greetings,

I am attempting to automate the pasting of excel charts from excel into a word document.

This is the part of the code that is giving me the problems:
Code:
        'Copy the data from Thisworkbook
        Chart.Copy
        'Paste into Word
        appWrd.Selection.Goto What:=wdGoToBookmark, Name:=BookMarkChart
        appWrd.Selection.PasteAndFormat Type:=wdChartLinked

after the macro execute appWrd.Selection.PasteAndFormat
I get a message that tells me that the command is not found.

What am I doing wrong?

-DaTaHuGGeR
 
PasteAndFormat isn't a method exposed by the word object model.
Take a look at the Selection.PasteSpecial method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I changed it to this and now I get an error that the datatype is incorrect.

No I am not going to argue with vba that the dataype is correct when it isn't....So what I am tring to say is where is a list of the datatypes available for each method.

I looked on msdn and I couldnt find a list any suggestions?

Code:
Chart.Copy
'Paste into Word
appWrd.Selection.Goto What:=wdGoToBookmark, Name:=BookMarkChart
appWrd.Selection.PasteSpecial DataType:=wdChart
 
Alright, so I tracked down the word constants.
I used the constant wdPasteMetafilePicture
and it pastes my object just like I want it too. However this puts me back at a problem. I tell the cursor to go to a certain location in the word doc and then I tell it to paste ( you can see this in my previous example). However when it does paste it paste where ever it wants do and disregards the bookmarks I have placed.



-DaTaHuGGeR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top