用VBA转PDF为图片插入的word中

用VBA转PDF为图片插入的word中,第1张

能,需要传两个参数,word路径和pdf路径。

代码可以做成wsf文件,通过C语言或者java调用

<job id="wtop">

<reference guid="{00020905-0000-0000-C000-000000000046}" comment="MSWord 2000 tag library,under HKEY_CLASSES_ROOTTypeLib"/>

<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>

恭喜你有了解决办法。

或者如果你电脑有PDF虚拟打印机的话,你可以不用安装另外的插件,用PDF打印机直接打印即可:

appWord.ActivePrinter = "CutePDF Writer"    '选择PDF打印机

appWord.PrintOut


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/8091831.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-13
下一篇 2023-04-13

发表评论

登录后才能评论

评论列表(0条)

保存