VB提示“用户定义类型未定义”,怎么解决

2024-12-05 12:06:48
推荐回答(3个)
回答1:

'用不同版本的办公软件可能有点不同
Private Sub Command1_Click()
Dim wdApp As New Word.Application '在这里提示用户定义类型未定义
Dim wdDoc As Word.Document
Dim strFileName As String
wdApp.Visible = False
strFileName = File1.Path + "\" + File1.FileName
Set wdDoc = wdApp.Documents.Open(strFileName)
wdDoc.SaveAs "c:\临时文件.RTF", 6
wdDoc.Close
wdApp.Quit
RichTextBox1.FileName = "c:\临时文件.RTF"
Kill "c:\临时文件.RTF"
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive '错误424 要求对象
End Sub

回答2:

注意这里选择“Microsoft Word X.0 Object Library”而不是Microsoft office X.0 Object Library

回答3:

到底怎么解决的呢