我正在尝试从 Excel 2007 进行一些相对简单的复制和粘贴到 Word 2007。我已经浏览了这个网站和其他网站,并且一直挂在同一件事上——下面代码的第三行一直给我“用户类型注释定义”错误消息。我真的很困惑,因为我刚刚从另一个解决方案中解除了这个(并且与我试图解除的其他解决方案有类似的问题)。有人可以告诉我是什么导致了错误,为什么?
Sub ControlWord()
' **** The line below gives me the error ****
Dim appWD As Word.Application
' Create a new instance of Word & make it visible
Set appWD = CreateObject("Word.Application.12")
appWD.Visible = True
'Find the last row with data in the spreadsheet
FinalRow = Range("A9999").End(xlUp).Row
For i = 1 To FinalRow
' Copy the current row
Worksheets("Sheet1").Rows(i).Copy
' Tell Word to create a new document
appWD.Documents.Add
' Tell Word to paste the contents of the clipboard into the new document
appWD.Selection.Paste
' Save the new document with a sequential file name
appWD.ActiveDocument.SaveAs Filename:="File" & i
' Close this new word document
appWD.ActiveDocument.Close
Next i
' Close the Word application
appWD.Quit
End Sub