Hello Everyone,
I've been working on this one for the past few days. I've found some useful threads here but I'm still stuck.
I'm copying a range of cells from excel and pasting into the active word document as an enhanced metafile. I would like to be able to resize the pasted picture in Word with the excel macro.
I've tried to use .selection.InLineShapes(1).height = 577 but keep getting an error message "Run-time error '5941':
The requested member of the collection does not exist."
I have the Word Object Library referenced. My code is as follows:
Sub PasteToWord()
Dim WDapp As Word.Application
Dim WDdoc As Word.Document
Set WDapp = GetObject(, "word.application")
Set WDdoc = WDapp.ActiveDocument
Sheets("TDS 2000").Select
ActiveSheet.Range("a1:h65").Copy
With WDapp
.Selection.PasteSpecial link:=False, DataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, DisplayAsIcon:=False
.Selection.InlineShapes(1).Height = 577 '<----- error on this line
.Selection.InsertBreak Type:=wdPageBreak
End With
end sub
I'm assuming that the error is coming from the InLineShapes(1). I don't know if that is referring to the right object. I was hoping I could resize while the object was selected in Word.
Any help is very much appreciated.
I've been working on this one for the past few days. I've found some useful threads here but I'm still stuck.
I'm copying a range of cells from excel and pasting into the active word document as an enhanced metafile. I would like to be able to resize the pasted picture in Word with the excel macro.
I've tried to use .selection.InLineShapes(1).height = 577 but keep getting an error message "Run-time error '5941':
The requested member of the collection does not exist."
I have the Word Object Library referenced. My code is as follows:
Sub PasteToWord()
Dim WDapp As Word.Application
Dim WDdoc As Word.Document
Set WDapp = GetObject(, "word.application")
Set WDdoc = WDapp.ActiveDocument
Sheets("TDS 2000").Select
ActiveSheet.Range("a1:h65").Copy
With WDapp
.Selection.PasteSpecial link:=False, DataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, DisplayAsIcon:=False
.Selection.InlineShapes(1).Height = 577 '<----- error on this line
.Selection.InsertBreak Type:=wdPageBreak
End With
end sub
I'm assuming that the error is coming from the InLineShapes(1). I don't know if that is referring to the right object. I was hoping I could resize while the object was selected in Word.
Any help is very much appreciated.