jfduroch
Mechanical
- Feb 27, 2003
- 20
I am trying to export an range of excel cells into word via a VBA macro and I would like to paste the cells in word as a picture. I have tried the following which doesnt work
as I get an error message on the paste command -runtime error 4605-command is not available - this concerns the paste as wdchartpicture :
Sub ExportDatasheet()
Dim DocWord As Word.Document
Dim AppWord As Word.Application
Dim WordDocPath As String
'request the path and word doc name where it should be send
WordDocPath = InputBox("Provide the Exact Path and Word file name where the datasheet is to be exported", "Input Path", "c:\Datasheet.doc"
' Copy excel Sheet
ThisWorkbook.Worksheets("Datasheet"
.Range("A1:K227"
.Copy
'establish link to Word
Set AppWord = New Word.Application
Application.DisplayAlerts = True
AppWord.ShowMe
AppWord.Visible = True
'open document Word
Set DocWord = AppWord.Documents.Open(WordDocPath, ReadOnly:=False)
With DocWord
.Range.PasteAndFormat Type:=wdChartPicture
End With
Application.CutCopyMode = False
DocWord.Application.ActiveDocument.Save
AppWord.Application.Quit
Set AppWord = Nothing
Set DocWord = Nothing
End Sub
Has anyone a tips to solve this problem. I have tried many things and exhausted all my resources.
R
as I get an error message on the paste command -runtime error 4605-command is not available - this concerns the paste as wdchartpicture :
Sub ExportDatasheet()
Dim DocWord As Word.Document
Dim AppWord As Word.Application
Dim WordDocPath As String
'request the path and word doc name where it should be send
WordDocPath = InputBox("Provide the Exact Path and Word file name where the datasheet is to be exported", "Input Path", "c:\Datasheet.doc"
' Copy excel Sheet
ThisWorkbook.Worksheets("Datasheet"
'establish link to Word
Set AppWord = New Word.Application
Application.DisplayAlerts = True
AppWord.ShowMe
AppWord.Visible = True
'open document Word
Set DocWord = AppWord.Documents.Open(WordDocPath, ReadOnly:=False)
With DocWord
.Range.PasteAndFormat Type:=wdChartPicture
End With
Application.CutCopyMode = False
DocWord.Application.ActiveDocument.Save
AppWord.Application.Quit
Set AppWord = Nothing
Set DocWord = Nothing
End Sub
Has anyone a tips to solve this problem. I have tried many things and exhausted all my resources.
R