Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
lee lee is offline
external usenet poster
 
Posts: 184
Default Excel to Word Run-time error 91

Below is part of a larger routine that copies pages from Excel and pastes
them into Word. This is running on numerous PC's with no problems, but on
one particular PC I'm getting a Run-Time Error 91, Object variable or with
block variable not set, that stops on wdapp.Selection.PasteSpecial.

Sub Page1()
'this subrountine prints the first page of the BOE
'select the range
Range("A2:N41").Select
'copy the range
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
'paste the range in word
wdapp.Selection.PasteSpecial Link:=False,
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdlinline, DisplayAsIcon:=False
End Sub

Any ideas why it doesn't work on only one P.C? I'm not sure where to start
looking since it it set up with the same applications and directory structure
as all of the rest.

Thanks,

Lee

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Excel to Word Run-time error 91

Lee,

Something to try.
1. Replace the word constants with their numeric value...
wdPasteEnhancedMetafile is 9
wdlinline is 0

2. Tell Excel which ranges and selections you referring to as
both applications use that terminology...
Excel.Range("A2:N41") and Excel.Selection

Even better...
Excel.Range("A2:N41").CopyPicture Appearance:=Excel.xlScreen, Format:=Excel.xlPicture
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Lee"
wrote in message
Below is part of a larger routine that copies pages from Excel and pastes
them into Word. This is running on numerous PC's with no problems, but on
one particular PC I'm getting a Run-Time Error 91, Object variable or with
block variable not set, that stops on wdapp.Selection.PasteSpecial.

Sub Page1()
'this subrountine prints the first page of the BOE
'select the range
Range("A2:N41").Select
'copy the range
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
'paste the range in word
wdapp.Selection.PasteSpecial Link:=False,
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdlinline, DisplayAsIcon:=False
End Sub

Any ideas why it doesn't work on only one P.C? I'm not sure where to start
looking since it it set up with the same applications and directory structure
as all of the rest.
Thanks,
Lee

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error while controlling Word from Excel JFamilo[_11_] Excel Programming 4 August 15th 05 01:58 AM
error excel if embedded in word documents MZ Excel Programming 2 March 10th 05 12:01 PM
Error using Word object library in Excel (VBA) LukeCarvey Excel Programming 3 March 4th 05 01:17 PM
Excel XP error message Run Time Error 91 Lenny[_3_] Excel Programming 1 March 3rd 05 10:15 PM


All times are GMT +1. The time now is 05:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"