需要传两个参数,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>