关于vba 在word中打开excel,然后复制其中单元格的数据,粘贴回wrod中

Sub M()
Dim wdapp As Object, exapp As Object
Selection.MoveDown Unit:=wdLine, Count:=3
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=5, Extend:=wdExtend
Set exapp = CreateObject("Word.Application")
exapp.Visible = True
Set exapp = Workbooks.Open("C:\ex.xls").workSheets("sheet1").Select
Rows("44:3").Copy
wdapp.Documents.Open ("C:\wd.doc")
wdapp.Visible = True
Selection.Paste
End Sub
然后在Rows上报错,编辑错误,子过程或函数未定义

主要代码为:

Sub test()
Set exapp = CreateObject("excel.Application")
exapp.Visible = True
Set xlsbook = exapp.Workbooks.Open("C:\ex.xls")
xlsbook.workSheets("sheet1").Rows("3:44").Copy
Selection.Paste
End Sub

温馨提示:答案为网友推荐,仅供参考
相似回答