Paste Excel data as picture

A

Andy

Hi All

I am trying to write a Word macro that will copy data from Excel and paste
it into a word document as a picture. Generally, if I don't know how to do
something in code I just record a similar macro and modify the code as
appropriate. However, this approach seems to have failed in this instance.
On record a macro to do this, Word creates the line:

Selection.PasteAndFormat (wdPasteDefault)

In recording the macro it works fine. However, when I insert this into my
code and run it, the Excel data is copied into a Word table. On the
offchance I have tried using the wdChartPicture constanct but that didn't
work (presumably because its not a chart!) and also used PasteSpecial instead
of PasteAndFormat but all to no avail. Does anybody know how to do this?

Thanks

Andy
 
H

Helmut Weber

Hi Andy,

it is always kind of wierd with dialogs,
and I don't understand it all,
nevertheless, this one seems to work:

Sub Macro2()
Dim oDlg As Dialog
Set oDlg = Dialogs(wdDialogEditPasteSpecial)
With oDlg
.Update
.datatype = "Bitmap"
.Execute
End With
End Sub

You may test what other datatypes there are, like:

Sub Macro2()
Dim oDlg As Dialog
Set oDlg = Dialogs(wdDialogEditPasteSpecial)
With oDlg
.Update
.datatype = "Bitmap"
.Display
MsgBox .datatype
.Update
.Display ' choose another type
MsgBox .datatype
.Update
.Display ' choose another type
MsgBox .datatype
End With
End Sub


--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
A

Andy

Hi Helmut

Thanks for this - it works perfectly!

On a completely irrelevent point - I've visited Friesenried in Bavaria and
think its a beautiful part of the world - I hope you enjoy living there!

Thanks

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top