能把WORD文件用VB转存为html吗?具体怎么实现?
楼主hitler45(Jery)2002-12-0911:03:17在VB/VBA提问
能把WORD文件用VB转存为html吗?具体怎么实现?问题点数:100、回复次数:4
1楼henrryzhang(NorthWolf)回复于2002-12-0911:08:12得分100
VB中引用WORD对象后用以下的语句保存即可
ActiveDocument.SaveAs FileName:="asdfgasdfsdsdffsd.htm", FileFormat:= _
wdFormatFilteredHTML, LockComments:=False, Password:="", AddToRecentFiles _
:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts _
:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
==========================================================================================================
把.doc打开后,另存为.html:
ActiveDocument.SaveAs FileName:= "Test.htm ", FileFormat:=wdFormatHTML, _
LockComments:=False, Password:= " ", AddToRecentFiles:=True, WritePassword _
:= " ", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
======================================================================================================
'引用Microsoft Word X.0 Object Library
Private Sub Command1_Click()
On Error GoTo connecterr
Dim wordApp As Object
Set wordApp = CreateObject( "word.application ")
wordApp.Visible = True
Dim myDoc As Object
Set myDoc = wordApp.Documents.Open( "c:\Test.dot ")
myDoc.SaveAs FileName:= "Test.htm ", FileFormat:=wdFormatHTML, _
LockComments:=False, Password:= " ", AddToRecentFiles:=True, WritePassword _
:= " ", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
myDoc.Close
wordApp.Quit
Set myDoc = Nothing
Set wordApp = Nothing
Exit Sub
connecterr:
End Sub
=======================================================================================================
Set mwa = New Word.Application
Dim sFileName As String
sFileName = App.Path & "/aaa.doc "
mwa.Documents.Open sFileName, , , , , , , , , , False
mwa.Visible = True
mwa.ChangeFileOpenDirectory App.Path
mwa.ActiveDocument.SaveAs App.Path & "/aaa.htm ", wdFormatHTML, False,
" ", True, " ", False, False, False, False, False
ActiveWindow.View.Type = wdWebView
mwa.ActiveDocum