Dim oWord As Word.Application
Set oWord = CreateObject("Word.Application")
oWord.Documents.Open FileName:="c:\test.doc"
oWord.Visible = True
Set oWord = Nothing
引用word application X.0
Set oWord = CreateObject("Word.Application")
oWord.Documents.Open FileName:="c:\test.doc"
oWord.Visible = True
Set oWord = Nothing
引用word application X.0
如果你的机器上没有,我告诉你到哪里下:
在MS的站上随便找一个DOC文件的链接,下面一个链接就是OfficeViewer。
分来。
具体代码见下:
public sub OpenFile(byval strWordFile as string)
Dim m_strTmpRtfFile As String
Dim objWord As Object
Dim objWordDocument As Word.Document
Const CLASSOBJECT = "Word.Application"
If (objWord Is Nothing) Then
Set objWord = CreateObject(CLASSOBJECT)
End If
m_strTmpRtfFile = app.path & "\tmp.rtf"
Set objWordDocument = objWord.Documents.Open FileName:=strWordFile)
objWord.Visible = False
objWord.PrintOut FileName:=strWordFile '打印word
objWordDocument.SaveAs m_strTmpRtfFile, wdFormatRTF '另存为RTF格式
Set objWordDocument = Nothing
objWord.Quit SaveChanges:=wdDoNotSaveChanges '退出Word
Set objWord = Nothing
if dir(m_strTmpRtfFile)<>"" then
RichTextBox1.LoadFile m_strTmpRtfFile '显示word
end if
end sub
好像还要先把word文档转成rtf格式?