How to use ASP to convert Doc to HTML

Source: Internet
Author: User
Documents. Add "newdoc.doc"
Activedocument. saveas filename: = "newdoc.htm", fileformat: = wdformathtml ,_
Lockcomments: = false, password: = "", addtorecentfiles: = true, writepassword _
: = "", Readonlyrecommended: = false, embedtruetypefonts: = false ,_
Savenativepictureformat: = false, saveformsdata: = false, saveasaoceletter: = _
False
Activewindow. View. type = wdwebview
---------------------------------------------------------------
 
Doc2html. vbs
 
'*************************************** *******************
'
'Call method: doc2html C:/doc2html C:/doc2html
'Call method: doc2html-s c:/doc2html/a.doc C:/doc2html
'
'*************************************** *******************
 
Dim objword
Dim objdoc
Dim objfso
Dim strsource
Dim strtarget
Dim bbatch
 
'The command line parameter can be obtained in three possible formats: [-S]. The source file directory or file to be converted is converted to the directory saved after HTML file conversion.
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)
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
 
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
 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.