ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pasting pictures from Excel to Word (2000) (https://www.excelbanter.com/excel-programming/327441-re-pasting-pictures-excel-word-2000-a.html)

Jim Cone

Pasting pictures from Excel to Word (2000)
 
Robin,

Are you doing this from Excel or from Word?
How are you opening the "other" application?

What I am getting at is... Are you sure you know
what "Selection" is referring to?

Jim Cone
San Francisco, USA


"Robin" wrote in message
...
I am trying to copy from Excel 2000 as a picture and then paste into Word
2000 as a picture. My code will select the contiguous range, but when it
gets to this command:

Selection.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlPicture

I get a run-time error 1004: Application-Defined or Object-Defined Error. I
haven't been able to determine which object is causing this error.

I tried earlier to simply copy the selection in Excel and PasteSpecial into
Word, but nothing seems to get pasted, even thought the code opens the
correct document. When the code finishes, I can manually paste the clipboard
contents, so I know it isn't empty.

Thanks to anyone who can help with this.


robin

Pasting pictures from Excel to Word (2000)
 
Jim, thanks for your suggestion. It solved that problem -
The code didn't know which selection to paste to, so I was able to fix that.
I've run into a another problem at the last part of my code - here is the
entire sub:

Private Sub Print_BL_Click()
'On Error Resume Next
Dim WordApp As Word.Application, BlankBL As Word.Document
Dim SaveWSName As String, BLNumber As String, SaveDocName As String
Application.Goto Reference:="BL_Number"
BLNumber = ActiveCell
SaveWSName = "\\Path\JIT001-" & BLNumber & ".xls"
ActiveWorkbook.SaveAs Filename:=SaveWSName, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Application.Goto Reference:="Print_Area"
Selection.Copy
SaveDocName = "\\Path\BILL OF LADING#" & BLNumber & ".doc"
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If WordApp Is Nothing Then
Set WordApp = New Word.Application
End If
On Error GoTo 0
If WordApp Is Nothing Then
MsgBox "Unable to load Word!", vbExclamation
End If
WordApp.Documents.Open "\\Path\BlankBL.doc"
WordApp.Visible = True
With WordApp.Selection
.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafilePicture, _
Placement:=1, DisplayAsIcon:=False
End With
ActiveDocument.SaveAs Filename:=SaveDocName, _
FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="",
ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, _
SaveFormsData:=False, SaveAsAOCELetter:= False

I'm getting a compile error at the next line, "Named Argument Not Found"
with "Filename:="" highlighted:

WordApp.ActiveDocument.PrintOut Filename:="",
Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=3, Pages:="",
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False,
PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0

Is this because I used FileName:=SaveDocName in the Save routine just above
this line? Below is the end of the Sub:

WordApp.Quit
Set BlankBL = Nothing
Set WordApp = Nothing
End Sub

I'm getting a
"Jim Cone" wrote:

Robin,

Are you doing this from Excel or from Word?
How are you opening the "other" application?

What I am getting at is... Are you sure you know
what "Selection" is referring to?

Jim Cone
San Francisco, USA


"Robin" wrote in message
...
I am trying to copy from Excel 2000 as a picture and then paste into Word
2000 as a picture. My code will select the contiguous range, but when it
gets to this command:

Selection.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlPicture

I get a run-time error 1004: Application-Defined or Object-Defined Error. I
haven't been able to determine which object is causing this error.

I tried earlier to simply copy the selection in Excel and PasteSpecial into
Word, but nothing seems to get pasted, even thought the code opens the
correct document. When the code finishes, I can manually paste the clipboard
contents, so I know it isn't empty.

Thanks to anyone who can help with this.



Jim Cone

Pasting pictures from Excel to Word (2000)
 
Robin,

According to my Word help file the "FileName" argument is only used
when the Application is printed, not when the ActiveDocument is
printed. Just remove it (and the comma).

Regards,
Jim Cone
San Francisco, USA


"Robin" wrote in message
...
Jim, thanks for your suggestion. It solved that problem -
The code didn't know which selection to paste to, so I was able to fix that.
I've run into a another problem at the last part of my code - here is the
entire sub:

Private Sub Print_BL_Click()


- snip -

I'm getting a compile error at the next line, "Named Argument Not Found"
with "Filename:="" highlighted:

WordApp.ActiveDocument.PrintOut Filename:="",
Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=3, Pages:="",
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False,
PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0

Is this because I used FileName:=SaveDocName in the Save routine just above
this line? Below is the end of the Sub:

WordApp.Quit
Set BlankBL = Nothing
Set WordApp = Nothing
End Sub




"Jim Cone" wrote:

Robin,
Are you doing this from Excel or from Word?
How are you opening the "other" application?
What I am getting at is... Are you sure you know
what "Selection" is referring to?
Jim Cone
San Francisco, USA




"Robin" wrote in message
...
I am trying to copy from Excel 2000 as a picture and then paste into Word
2000 as a picture. My code will select the contiguous range, but when it
gets to this command:

Selection.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlPicture

I get a run-time error 1004: Application-Defined or Object-Defined Error. I
haven't been able to determine which object is causing this error.

I tried earlier to simply copy the selection in Excel and PasteSpecial into
Word, but nothing seems to get pasted, even thought the code opens the
correct document. When the code finishes, I can manually paste the clipboard
contents, so I know it isn't empty.

Thanks to anyone who can help with this.



robin

Pasting pictures from Excel to Word (2000)
 
Thanks, Jim! Got everything working now. I appreciate all you help.

"Jim Cone" wrote:

Robin,

According to my Word help file the "FileName" argument is only used
when the Application is printed, not when the ActiveDocument is
printed. Just remove it (and the comma).

Regards,
Jim Cone
San Francisco, USA


"Robin" wrote in message
...
Jim, thanks for your suggestion. It solved that problem -
The code didn't know which selection to paste to, so I was able to fix that.
I've run into a another problem at the last part of my code - here is the
entire sub:

Private Sub Print_BL_Click()


- snip -

I'm getting a compile error at the next line, "Named Argument Not Found"
with "Filename:="" highlighted:

WordApp.ActiveDocument.PrintOut Filename:="",
Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=3, Pages:="",
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False,
PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0

Is this because I used FileName:=SaveDocName in the Save routine just above
this line? Below is the end of the Sub:

WordApp.Quit
Set BlankBL = Nothing
Set WordApp = Nothing
End Sub




"Jim Cone" wrote:

Robin,
Are you doing this from Excel or from Word?
How are you opening the "other" application?
What I am getting at is... Are you sure you know
what "Selection" is referring to?
Jim Cone
San Francisco, USA




"Robin" wrote in message
...
I am trying to copy from Excel 2000 as a picture and then paste into Word
2000 as a picture. My code will select the contiguous range, but when it
gets to this command:

Selection.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlPicture

I get a run-time error 1004: Application-Defined or Object-Defined Error. I
haven't been able to determine which object is causing this error.

I tried earlier to simply copy the selection in Excel and PasteSpecial into
Word, but nothing seems to get pasted, even thought the code opens the
correct document. When the code finishes, I can manually paste the clipboard
contents, so I know it isn't empty.

Thanks to anyone who can help with this.




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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com