word转成html的问题

mdongs 2003-08-24 09:57:13
各位大虾你们好,请问怎么样编写程序才能把word文档转化为html文件,并且把文件保存到自己的服务器上呢?谢谢了!
...全文
84 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hzqq 2003-08-24
  • 打赏
  • 举报
回复
还有,word自己有另存为Web页功能的
hzqq 2003-08-24
  • 打赏
  • 举报
回复
用word的宏
语法和asp差不多
自己看看吧
ahuiok 2003-08-24
  • 打赏
  • 举报
回复
用word把版面排好后, 点文件, 点另存为网页... 生成htm。例如生成1.htm

安装IIS或者pws,建立一个站点,把目录指向存放1.htm的路径。
xuya 2003-08-24
  • 打赏
  • 举报
回复
高人的做法:你可以转成asp语法,程序唯一的不足在于运行完之后word.exe在进程里没完全消失,我也修改不好,希望原作可以看到并加以纠正


'doc2html.vbs
'**********************************************************
'
' 调用方法:doc2html c:\doc2html c:\doc2html
' 调用方法:doc2html -s c:\doc2html\a.doc c:\doc2html
' 存在问题:无法释放进程中的word!
'**********************************************************

Dim Objword
Dim Objdoc
Dim Objfso
Dim Strsource
Dim Strtarget
Dim Bbatch

'得到命令行参数,有三种可能的格式:[-s] 要进行转换的源文件目录或文件 转换成Html文件后保存的目录
Function Getparams()
Dim Objarg
If Wscript.Arguments.Count >= 2 Then
If Wscript.Arguments.Item(0) = "-s" Or Wscript.Arguments.Item(0) = "-S" Then
Strsource = Wscript.Arguments.Item(1)
Strtarget = Wscript.Arguments.Item(2)
Bbatch = False
Else
Strsource = Wscript.Arguments.Item(0)
Strtarget = Wscript.Arguments.Item(1)
Bbatch = True
End If
Else
Wscript.Quit(1)
End If
End Function

Function Batchprocessing()
Dim Objfolder
Dim Objfile
Dim Lpos
Dim Strfilename
Lpos = 0
Set Objfolder = Objfso.Getfolder(Strsource)
For Each Objfile In Objfolder.Files
Lpos = Instr(1,Mid(Objfile.Path,Len(Objfile.Path) - 3,4),"Doc",1)
If Lpos > 0 Then
Strfilename = Objfso.Getbasename(Objfile.Path) 'Getbasename是取除后缀以外的文件名
Wordinterface Objfile.Path,Strfilename
End If
Next
End Function


Function Singleprocessing()
Dim Objfile
Set Objfile = Objfso.Getfile(Strsource)
Strfilename = Objfso.Getbasename(Objfile.Path)
Wordinterface Objfile.Path,Strfilename
End Function

Function Wordinterface(Strfilename,Formattedfilename)
Objword.Documents.Open Strfilename
Set Objdoc = Objword.Activedocument
'Stop
'set The Title Of The Document To Match The Filename
Objdoc.Builtindocumentproperties(1) = Formattedfilename
'1 = Wdpropertytitle In Vba
msgbox Strtarget & "\" & Formattedfilename & ".htm"
Objdoc.Saveas Strtarget & "\" & Formattedfilename & ".htm",8
'objdoc.Saveas "C:\Doc2Html\" & Formattedfilename & ".htm",8
On Error Resume Next
Objdoc.Close
End Function

'stop
Set Objfso = Createobject("Scripting.FileSystemObject")
Set Objword = Createobject("Word.Application")
Objword.Visible = False
Call Getparams

If Bbatch Then
Call Batchprocessing
Else
Call Singleprocessing
End If



Objword.Quit
Set Objword = Nothing

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧