我正在尝试使用 Office 自动化打开 Word 文档。问题是我想在不调用 Document_Open 宏的情况下打开它。有没有办法做到这一点?
下面的相关行是 wordApp.Documents.Open()
Imports Microsoft.Office.Interop
Public Class WordFunctions
Public Shared Function ConvertToDoc(ByVal file As String) As Boolean
Dim wordDoc As Word.Document
Dim wordApp As Word.Application
Try
wordApp = CreateObject("Word.Application", "")
Catch ex As Exception
Return False
End Try
Try
wordApp.Caption = "Automated Word Instance"
wordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone
wordDoc = wordApp.Documents.Open(FileName:=file, Visible:=False, ConfirmConversions:=False)
wordDoc.SaveAs(FileName:=file + ".doc", FileFormat:=Word.WdSaveFormat.wdFormatDocument)
wordDoc.Activate()
wordDoc.Close()
Return True
Catch ex As Exception
Return False
Finally
wordApp.Quit(SaveChanges:=False)
End Try
End Function
End Class