[英]Copy and Paste active Word document to active Excel document using VBA
Is it possible to copy the contents of a word document (Which is open) into an active excel document by using VBA ? 是否可以使用VBA将Word文档(打开的文档)的内容复制到活动的excel文档中?
I am using excel / word 2013 我正在使用Excel / Word 2013
Hi i found the solution to my own question. 嗨,我找到了解决自己问题的方法。
In the Excel workbook you must set up the following 在Excel工作簿中,您必须设置以下内容
'Tools -> References -> Microsoft Forms 2.0 Object Library' , or you will get a "Compile error: user-defined type not defined" “工具->引用-> Microsoft Forms 2.0对象库”,否则您将收到“编译错误:未定义用户定义的类型”
Sub ClipboardToExcel()
Dim MyData As DataObject
Dim strClip As String
Set MyData = New DataObject
MyData.GetFromClipboard
strClip = MyData.GetText
Sheets("sheet2").Select
Range("A1").Select
ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=
_
False, NoHTMLFormatting:=True
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.