能,需要傳兩個參數,word路徑和pdf路徑。
代碼可以做成wsf文件,通過C語言或者java調用
<job id="wtop">
<reference guid="{00020905-0000-0000-C000-000000000046}" comment="MSWord 2000 tag library,under HKEY_CLASSES_ROOT\TypeLib\"/>
<script language="VBScript">
Option Explicit
Dim Home_file
Dim outdoc_file
'If WScript.Arguments.Count < 2 Then
' MsgBox "Usage: t1 <Home_file> <outdoc_file> "
' WScript.Quit
'End If
Home_file = WScript.Arguments(0)
outdoc_file = WScript.Arguments(1)
Dim WordApp
Set WordApp = CreateObject("Word.Application")
With WordApp
.Visible = False '設置word為可見
With .Options
.CheckSpellingAsYouType = False '不檢查拼寫
.CheckGrammarAsYouType = False '不檢查語法
End With
'打開模板文件
.Documents.Open(Home_file)
.Documents(1).Activate '激活文檔
Dim doc
Set doc = .ActiveDocument '得到這個使用中的文件
doc.ExportAsFixedFormat outdoc_file, 17, False, 0, 0, 1, 1, 0, True, True, 0, True, True, False
doc.Close False
With .Options
.CheckSpellingAsYouType = True
.CheckGrammarAsYouType = True
End With
.Quit
End With
</script>
</job>