0
我要出口一些細胞在Excel中的Word內容,我想做這樣的的Excel到Word:用戶定義類型沒有定義,缺少的詞庫參考
Sub CreateNewWordDoc()
' to test this code, paste it into an Excel module
' add a reference to the Word-library
' create a new folder named C:\Foldername or edit the filnames in the code
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim i As Integer
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add
' or
'Set wrdDoc = wrdApp.Documents.Open("C:\Foldername\Filename.doc")
' sample word operations
With wrdDoc
For i = 1 To 100
.Content.InsertAfter "Here is a sample test line #" & i
.Content.InsertParagraphAfter
Next i
If Dir("C:\Foldername\MyNewWordDoc.doc") <> "" Then
Kill "C:\Foldername\MyNewWordDoc.doc"
End If
.SaveAs ("C:\Foldername\MyNewWordDoc.doc")
.Close ' close the document
End With
wrdApp.Quit ' close the Word application
Set wrdDoc = Nothing
Set wrdApp = Nothing
End Sub
但是當測試功能的Excel說:「編譯錯誤:用戶定義類型沒有定義」 我想這個ia libray丟失,但我找不到任何合適的工具 - >參考(VBA), 像微軟Office世界或Microsft Word ...哪裏可以我找到他們了?
我瀏覽並手動添加它,問題得到解決:) – Andiana 2014-10-10 15:26:08