Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am trying to export an range of e

Status
Not open for further replies.

jfduroch

Mechanical
Feb 27, 2003
20
0
0
FR
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

 
Replies continue below

Recommended for you

Code:
Replace this ->
   With DocWord
      .Range.PasteAndFormat Type:=wdChartPicture
   End With

with this ->
   DocWord.Range.PasteSpecial Link:=False, DataType:=wdPasteMetafilePicture
 
Status
Not open for further replies.
Back
Top