{"id":7353,"date":"2016-09-26T14:16:57","date_gmt":"2016-09-26T05:16:57","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=7353"},"modified":"2016-09-26T14:16:57","modified_gmt":"2016-09-26T05:16:57","slug":"pdf%e3%82%92%e4%bb%96%e3%81%ae%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e5%bd%a2%e5%bc%8f%e3%81%ab%e5%a4%89%e6%8f%9b%e3%81%99%e3%82%8bvba%e3%83%9e%e3%82%af%e3%83%ad","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=7353","title":{"rendered":"PDF\u3092\u4ed6\u306e\u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f\u306b\u5909\u63db\u3059\u308bVBA\u30de\u30af\u30ed"},"content":{"rendered":"<p>\u300c<span style=\"color: #ff0000; font-weight: bold;\">PDF \u5909\u63db Word VBA<\/span>\u300d\u3068\u3044\u3063\u305f\u30ad\u30fc\u30ef\u30fc\u30c9\u691c\u7d22\u3067\u306e\u30a2\u30af\u30bb\u30b9\u304c\u3042\u308a\u307e\u3057\u305f\u3002<br \/>\n\u30de\u30af\u30ed\u3067PDF\u30d5\u30a1\u30a4\u30eb\u3092Word\u30d5\u30a1\u30a4\u30eb\u306b\u5909\u63db\u3059\u308b\u65b9\u6cd5\u3092\u63a2\u3057\u3066\u3044\u308b\u65b9\u3060\u308d\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>Acrobat JavaScript\u306eDoc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u306f\u5225\u306e\u5f62\u5f0f\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306e<a href=\"http:\/\/help.adobe.com\/en_US\/acrobat\/acrobat_dc_sdk\/2015\/HTMLHelp\/index.html#t=Acro12_MasterBook%2FJS_API_AcroJS%2FDoc_methods.htm%23TOC_saveAsbc-93&#038;rhtocid=_6_1_8_23_1_92\" title=\"Acrobat DC SDK Documentation\" target=\"_blank\">saveAs<\/a>\u30e1\u30bd\u30c3\u30c9\u304c\u7528\u610f\u3055\u308c\u3066\u304a\u308a\u3001\u305d\u306e\u30e1\u30bd\u30c3\u30c9\u3092GetJSObject\u7d4c\u7531\u3067\u547c\u3073\u51fa\u3059\u3053\u3068\u3067\u3001VBA\u30de\u30af\u30ed\u304b\u3089\u3067\u3082\u51e6\u7406\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Option Explicit\r\n\r\nPrivate Enum Conv\r\n  TypeDoc = 0\r\n  TypeDocx = 1\r\n  TypeEps = 2\r\n  TypeHtml = 3\r\n  TypeJpeg = 4\r\n  TypeJpf = 5\r\n  TypePdfA = 6\r\n  TypePdfE = 7\r\n  TypePdfX = 8\r\n  TypePng = 9\r\n  TypePs = 10\r\n  TypeRft = 11\r\n  TypeTiff = 12\r\n  TypeTxtA = 13\r\n  TypeTxtP = 14\r\n  TypeXlsx = 15\r\n  TypeSpreadsheet = 16\r\n  TypeXml = 17\r\nEnd Enum\r\n\r\nPublic Sub Sample()\r\n  ConvertPDF &quot;C:\\Test\\PDF\\Sample.pdf&quot;, TypeDocx\r\nEnd Sub\r\n\r\nPrivate Sub ConvertPDF(ByVal TargetFilePath As String, _\r\n                       ByVal TargetConvType As Conv)\r\n'PDF\u3092\u4ed6\u306e\u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f\u306b\u5909\u63db\r\n  Dim jso As Object\r\n  Dim convid As String\r\n  Dim ext As String\r\n  Dim fp As String, fn As String\r\n  \r\n  '\u30d5\u30a9\u30eb\u30c0\u30d1\u30b9\u3068\u30d5\u30a1\u30a4\u30eb\u540d\u53d6\u5f97\r\n  With CreateObject(&quot;Scripting.FileSystemObject&quot;)\r\n    fp = AddPathSeparator(.GetParentFolderName(TargetFilePath))\r\n    fn = .GetBaseName(TargetFilePath)\r\n  End With\r\n  \r\n  convid = GetConvID(TargetConvType)\r\n  ext = GetExtension(TargetConvType)\r\n  With CreateObject(&quot;AcroExch.PDDoc&quot;)\r\n    If .Open(TargetFilePath) = True Then\r\n      Set jso = .GetJSObject\r\n      CallByName jso, &quot;saveAs&quot;, VbMethod, _\r\n                 fp &amp; fn &amp; &quot;.&quot; &amp; ext, convid\r\n      .Close\r\n    End If\r\n  End With\r\nEnd Sub\r\n\r\nPrivate Function GetConvID(ByVal ConvType As Conv) As String\r\n'cConvID\u53d6\u5f97\r\n  Dim v As Variant\r\n  \r\n  v = Array(&quot;com.adobe.acrobat.doc&quot;, &quot;com.adobe.acrobat.docx&quot;, &quot;com.adobe.acrobat.eps&quot;, _\r\n            &quot;com.adobe.acrobat.html&quot;, &quot;com.adobe.acrobat.jpeg&quot;, &quot;com.adobe.acrobat.jp2k&quot;, _\r\n            &quot;com.callas.preflight.pdfa&quot;, &quot;com.callas.preflight.pdfe&quot;, &quot;com.callas.preflight.pdfx&quot;, _\r\n            &quot;com.adobe.acrobat.png&quot;, &quot;com.adobe.acrobat.ps&quot;, &quot;com.adobe.acrobat.rtf&quot;, _\r\n            &quot;com.adobe.acrobat.tiff&quot;, &quot;com.adobe.acrobat.accesstext&quot;, &quot;com.adobe.acrobat.plain-text&quot;, _\r\n            &quot;com.adobe.acrobat.xlsx&quot;, &quot;com.adobe.acrobat.spreadsheet&quot;, &quot;com.adobe.acrobat.xml-1-00&quot;)\r\n  GetConvID = v(ConvType)\r\nEnd Function\r\n\r\nPrivate Function GetExtension(ByVal ConvType As Conv) As String\r\n'\u62e1\u5f35\u5b50\u53d6\u5f97\r\n  Dim v As Variant\r\n  \r\n  v = Array(&quot;doc&quot;, &quot;docx&quot;, &quot;eps&quot;, &quot;html&quot;, &quot;jpeg&quot;, &quot;jpf&quot;, &quot;pdf&quot;, &quot;pdf&quot;, &quot;pdf&quot;, &quot;png&quot;, _\r\n            &quot;ps&quot;, &quot;rft&quot;, &quot;tiff&quot;, &quot;txt&quot;, &quot;txt&quot;, &quot;xlsx&quot;, &quot;xml&quot;, &quot;xml&quot;)\r\n  GetExtension = v(ConvType)\r\nEnd Function\r\n\r\nPrivate Function AddPathSeparator(ByVal s As String)\r\n  If Right(s, 1) &lt;&gt; ChrW(92) Then s = s &amp; ChrW(92)\r\n  AddPathSeparator = s\r\nEnd Function<\/pre>\n<p>saveAs\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u969b\u3001\u5909\u63db\u5f62\u5f0f\u3092\u6587\u5b57\u5217(<span style=\"color: #ff0000; font-weight: bold;\">cConvID<\/span>)\u3068\u3057\u3066\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u4e0a\u8a18\u30b3\u30fc\u30c9\u3067\u306f\u5f62\u5f0f\u3092\u6307\u5b9a\u3057\u3084\u3059\u3044\u3088\u3046\u3001\u5217\u6319\u578b\u3092\u5b9a\u7fa9\u3057\u3066\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u300cPDF \u5909\u63db Word VBA\u300d\u3068\u3044\u3063\u305f\u30ad\u30fc\u30ef\u30fc\u30c9\u691c\u7d22\u3067\u306e\u30a2\u30af\u30bb\u30b9\u304c\u3042\u308a\u307e\u3057\u305f\u3002 \u30de\u30af\u30ed\u3067PDF\u30d5\u30a1\u30a4\u30eb\u3092Word\u30d5\u30a1\u30a4\u30eb\u306b\u5909\u63db\u3059\u308b\u65b9\u6cd5\u3092\u63a2\u3057\u3066\u3044\u308b\u65b9\u3060\u308d\u3046\u3068\u601d\u3044\u307e\u3059\u3002 Acrobat JavaScript\u306eDoc\u30aa\u30d6 [&hellip;]","protected":false},"author":1,"featured_media":7108,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"[PDF\u3092\u4ed6\u306e\u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f\u306b\u5909\u63db\u3059\u308bVBA\u30de\u30af\u30ed]","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,48,49,58,136],"tags":[],"class_list":["post-7353","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-excel-office","category-word-office","category-powerpoint","category-acrobat"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Acrobat.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-1UB","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7353"}],"version-history":[{"count":2,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7353\/revisions"}],"predecessor-version":[{"id":7355,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7353\/revisions\/7355"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7108"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}