怎麼用asp把doc轉換成html

來源:互聯網
上載者: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  
 
'**********************************************************  
'  
'        調用方法:doc2html  c:/doc2html  c:/doc2html  
'        調用方法:doc2html  -s  c:/doc2html/a.doc  c:/doc2html  
'  
'**********************************************************  
 
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)  
                             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
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.