0
我正在尝试将图表复制到Word中。我抬头看了一眼method,说做这样的事情:将图表从Excel复制到Word
Dim wordApp As Object
Dim wordDoc As Object
Set wordApp = CreateObject("Word.Application")
wordApp.Visible = True
Set wordDoc = wordApp.Documents.Add
With ThisWorkbook
.Sheets("Sheet1").ChartObjects(1).Activate
.ActiveChart.ChartArea.Copy
End With
With Selection
.PasteSpecial Link:=False, DataType:=wdInLine, _
Placement:=wdInLine
End With
wordApp.Documents.Close
wordApp.Application.Quit
我试图改变With selection
部分只是wordApp.Documents.Selection.Pastespecial
这会导致一些奇怪的事情发生,并最终以某种方式粘贴在第一页的屏幕截图工作簿和Excel崩溃。任何建议感激。
With Selection
.PasteSpecial Link:=False, DataType:=wdInLine, _
Placement:=wdInLine
End With
可以解决你的问题,这个改变它:
With wordDoc.Application.Selection
.PasteSpecial Link:=False, DataType:=wdInLine, _
Placement:=wdInLine
End With
说明:从Excel宏运行代码
这很有道理,谢谢。这现在给我一个错误:“Word遇到问题” – teepee