{"id":8917,"date":"2024-05-21T20:01:01","date_gmt":"2024-05-21T12:01:01","guid":{"rendered":""},"modified":"2024-05-21T20:01:01","modified_gmt":"2024-05-21T12:01:01","slug":"vbakf_word\u4e2d\u7684VBA\u5e94\u7528\u5b9e\u4f8b\u300c\u5efa\u8bae\u6536\u85cf\u300d","status":"publish","type":"post","link":"https:\/\/mushiming.com\/8917.html","title":{"rendered":"vbakf_word\u4e2d\u7684VBA\u5e94\u7528\u5b9e\u4f8b\u300c\u5efa\u8bae\u6536\u85cf\u300d"},"content":{"rendered":"

word\u53e6\u5b58\u6210PDF\u5982\u679c\u7528\u5b8f\u7684\u65b9\u5f0f\u89e3\u51b3\uff0c\u53ef\u4ee5\u5f55\u5236\u5982\u4e0b\uff1a<\/p>\n

Sub \u5b8f1()\n'\n' \u5b8f1 \u5b8f\n'\n'\n    ActiveDocument.ExportAsFixedFormat OutputFileName:= _\n        \"X:\\AHK\\office\\\u6d4b\u8bd5\u53e6\u5b58\u6210pdf.pdf\", ExportFormat:=wdExportFormatPDF, _\n        OpenAfterExport:=True, OptimizeFor:=wdExportOptimizeForPrint, Range:= _\n        wdExportAllDocument, From:=1, To:=1, Item:=wdExportDocumentContent, _\n        IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:= _\n        wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:= _\n        True, UseISO19005_1:=False\nEnd Sub<\/code><\/pre>\n

\u4e0d\u597d\u7684\u5730\u65b9\u662f\u6bcf\u6b21\u90fd\u9700\u8981\u542f\u7528\u5b8f\u624d\u884c\uff0c\u5982\u4f55\u4e0d\u7528\u542f\u52a8\u5b8f\u5462\uff0c\u90a3\u636e\u6211\u6240\u77e5\u6700\u597d\u7684\u529e\u6cd5\u5c31\u662f\u5199ahk\u811a\u672c\uff0c\u5728ahk\u5708\u4e2d\u620f\u79f0\u5199vbk\u3002<\/p>\n<\/p>\n

\u4ee5\u4e0a\u5b8fvba\u6539\u5199vbk\u5982\u4e0b:<\/p>\n

oWord:=ComObjActive(\"Word.Application\")\noWord.ActiveDocument.ExportAsFixedFormat(OutputFileName:=A_Desktop \"\\test4.pdf\"\n    , ExportFormat:=wdExportFormatPDF\n    , OpenAfterExport:=True\n    , OptimizeFor:=wdExportOptimizeForPrint\n    , Range:= wdExportAllDocument\n    , From:=1\n    , To:=1\n    , Item:=wdExportDocumentContent\n    , IncludeDocProps:=True\n    , KeepIRM:=True\n    , CreateBookmarks:=wdExportCreateNoBookmarks\n    , DocStructureTags:=True\n    , BitmapMissingFonts:=True\n    , UseISO19005_1:=False)\n oWord := \"\"<\/code><\/pre>\n

\u65b9\u6cd5\u5c31\u662f \u53bb\u6389\u539f\u6765\u5b8f\u4e2d\u7684_\u8fde\u63a5\u7b26\u5c06\u540e\u9762\u5185\u5bb9\u63d0\u4e0a\u6765\uff0c\u5e76\u5728\u9017\u53f7\u524d\u9762\u56de\u8f66 \u4f7f\u5f97\u6bcf\u884c\u72ec\u7acb\u6210\u884c\uff0c\u5728\u524d\u9762\u521b\u5efaoWord := ComObjActive(\"Word.Application\")\u5bf9\u8c61\u3002\u7528\u8be5com\u5bf9\u8c61\u8c03\u7528\u76f8\u5173\u51fd\u6570oWord.ActiveDocument.ExportAsFixedFormat<\/p>\n

\u5e76\u628a\u53c2\u6570\u7528\u62ec\u53f7\u62ec\u8d77\u6765\u3002<\/p>\n

\u505a\u5230\u4ee5\u4e0a\u8fd8\u5dee\u5173\u952e\u4e00\u6b65\uff0c\u5c31\u662f\u5c06\u5fae\u8f6f\u7684\u4e00\u4e9b\u5e38\u6570\u58f0\u660e\u4e00\u4e0b\uff1a<\/p>\n

wdExportFormatPDF := 17\nwdExportOptimizeForPrint := 0\nwdExportAllDocument := 0\nwdExportDocumentContent := 0\nwdExportCreateNoBookmarks := 0 <\/code><\/pre>\n

\u5408\u8d77\u6765\u5982\u4e0b\uff0c\u81f3\u4e8e\u5982\u4f55\u52a0\u70ed\u952e\u90a3\u662fahk\u62ff\u624b\u597d\u620f\uff0c\u8fd9\u91cc\u5c31\u4e0d\u8d58\u8ff0\u4e86\uff1a<\/p>\n

\nwdExportFormatPDF := 17\nwdExportOptimizeForPrint := 0\nwdExportAllDocument := 0\nwdExportDocumentContent := 0\nwdExportCreateNoBookmarks := 0 \n\n\noWord:=ComObjActive(\"Word.Application\")\noWord.ActiveDocument.ExportAsFixedFormat(OutputFileName:=A_Desktop \"\\test4.pdf\"\n    , ExportFormat:=wdExportFormatPDF\n    , OpenAfterExport:=True\n    , OptimizeFor:=wdExportOptimizeForPrint\n    , Range:= wdExportAllDocument\n    , From:=1\n    , To:=1\n    , Item:=wdExportDocumentContent\n    , IncludeDocProps:=True\n    , KeepIRM:=True\n    , CreateBookmarks:=wdExportCreateNoBookmarks\n    , DocStructureTags:=True\n    , BitmapMissingFonts:=True\n    , UseISO19005_1:=False)\n \noWord := \"\"<\/code><\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"vbakf_word\u4e2d\u7684VBA\u5e94\u7528\u5b9e\u4f8b\u300c\u5efa\u8bae\u6536\u85cf\u300dword\u53e6\u5b58\u6210PDF\u5982\u679c\u7528\u5b8f\u7684\u65b9\u5f0f\u89e3\u51b3\uff0c\u53ef\u4ee5\u5f55\u5236\u5982\u4e0b\uff1aSub\u5b8f1()''\u5b8f1\u5b8f''ActiveDocument.E...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8917"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=8917"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8917\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=8917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=8917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=8917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}