excel macro in excel 2003 not working in excel 2010

mjp155

New Member
Joined
Oct 29, 2010
Messages
29
I produce a spreadsheet in excel 2003 where there is a macro that exports a named range into a word 2003 document. This works well for someone that has office 2003 or 2007, but it doesn't seem to work for someone using excel 2010.
These users get the following error: Microsoft Visual Basic, Runtime error 1004, Copypicture method of range class failed

This is the beginning of the VBA Code:
Dim wdApp As Word.Application, wdDoc As Word.Document, ws As Worksheet
Application.ScreenUpdating = False
Application.StatusBar = "Creating new document..."
Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Add

I know that the Word Object Library in VBE 2003 is 11.0 while it is 14.0 in VBE 2010....could this be the s
ource of the error?

Can this macro code work using a 14.0 Word Object Library?
 
Last edited:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Just needs some updated syntax, is all (i think)

Code:
Dim wdApp As Word.Application, wdDoc As Word.Document, ws As Worksheet
Application.ScreenUpdating = False
Application.StatusBar = "Creating new document..."
 
'Turn off errors for a moment while we try to hook into an open instance of word
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
 
'If word isn't open we got an error (code 0).  In this case, open word
If Err.Number <> 0 Then
    Set wdApp = CreateObject("Word.Application")
End If
 
'need to be able to see it, probably
wdApp.Visible = True
 
'add a new document
Set wdDoc = wdApp.Documents.Add
 
'turn that error barfing back on
On Error GoTo 0
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top