{"id":10256,"date":"2018-04-10T15:00:00","date_gmt":"2018-04-10T06:00:00","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=10256"},"modified":"2018-04-10T15:32:18","modified_gmt":"2018-04-10T06:32:18","slug":"%e3%83%89%e3%83%a9%e3%83%83%e3%82%b0%ef%bc%86%e3%83%89%e3%83%ad%e3%83%83%e3%83%97%e3%81%97%e3%81%9foffice%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92pdf%e3%81%ab%e5%a4%89%e6%8f%9b%e3%81%99%e3%82%8bvb","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=10256","title":{"rendered":"\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3057\u305fOffice\u30d5\u30a1\u30a4\u30eb\u3092PDF\u306b\u5909\u63db\u3059\u308bVBScript"},"content":{"rendered":"<p>\u8907\u6570\u306eExcel\u30d5\u30a1\u30a4\u30eb\u3092PDF\u306b\u4e00\u62ec\u5909\u63db\u3059\u308b\u5fc5\u8981\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u7c21\u5358\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Option Explicit\r\n\r\nDim fp\r\nDim fso\r\nDim args\r\nDim i\r\n\r\nConst msoFalse = 0\r\nConst msoTrue = -1\r\nConst xlTypePDF = 0\r\nConst xlQualityStandard = 0\r\nConst wdExportFormatPDF = 17\r\nConst wdExportOptimizeForPrint = 0\r\nConst wdExportAllDocument = 0\r\nConst wdExportDocumentContent = 0\r\nConst wdExportCreateWordBookmarks = 2\r\nConst wdDoNotSaveChanges = 0\r\nConst ppSaveAsPDF = 32\r\n\r\nSet fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)\r\nSet args = WScript.Arguments\r\n\r\nIf args.Count &lt; 1 Then\r\n  MsgBox &quot;\u5f53\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u30d5\u30a1\u30a4\u30eb\u3092\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3057\u3066\u51e6\u7406\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;, vbExclamation + vbSystemModal\r\n  WScript.Quit\r\nEnd If\r\n\r\nFor i = 0 To args.Count - 1\r\n  fp = fso.GetParentFolderName(args(i)) &amp; ChrW(92) &amp; fso.GetBaseName(args(i)) &amp; &quot;.pdf&quot;\r\n  Select Case LCase(fso.GetExtensionName(args(i)))\r\n    Case &quot;doc&quot;, &quot;docx&quot;, &quot;dotm&quot; 'Word\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\r\n      With CreateObject(&quot;Word.Application&quot;)\r\n        .Visible = True\r\n        With .Documents.Open(args(i))\r\n          .ExportAsFixedFormat fp, wdExportFormatPDF, False, wdExportOptimizeForPrint, wdExportAllDocument, , , _\r\n                                   wdExportDocumentContent, False, False, wdExportCreateWordBookmarks, True, True, False\r\n          .Close wdDoNotSaveChanges\r\n        End With\r\n        .Quit\r\n      End With\r\n    Case &quot;xls&quot;, &quot;xlsx&quot;, &quot;xlsm&quot; 'Excel\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\r\n      With CreateObject(&quot;Excel.Application&quot;)\r\n        .Visible = True\r\n        With .Workbooks.Open(args(i))\r\n          .ExportAsFixedFormat xlTypePDF, fp, xlQualityStandard, False, False, , , False\r\n          .Close False\r\n        End With\r\n        .Quit\r\n      End With\r\n    Case &quot;ppt&quot;, &quot;pptx&quot;, &quot;pptm&quot; 'PowerPoint\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\r\n      With CreateObject(&quot;PowerPoint.Application&quot;)\r\n        .Visible = True\r\n        With .Presentations.Open(args(i))\r\n          .SaveAs fp, ppSaveAsPDF, msoTrue 'ExportAsFixedFormat\u306f\u30a8\u30e9\u30fc\u306b\u306a\u3063\u305f\u305f\u3081SaveAs\u4f7f\u7528\r\n          .Close\r\n        End With\r\n        .Quit\r\n      End With\r\n  End Select\r\nNext\r\n\r\nMsgBox &quot;\u51e6\u7406\u304c\u7d42\u4e86\u3057\u307e\u3057\u305f\u3002&quot;, vbInformation + vbSystemModal<\/pre>\n<p>\u3064\u3044\u3067\u306bWord\u3084PowerPoint\u306b\u3082\u5bfe\u5fdc\u3055\u305b\u305f\u306e\u3067\u3059\u304c\u3001PowerPoint\u306e\u5834\u5408\u306f\u3001ExportAsFixedFormat\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u304a\u3046\u3068\u3059\u308b\u3068\u300c\u578b\u304c\u4e00\u81f4\u3057\u307e\u305b\u3093\u300d\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u305f\u3081\u3001SaveAs\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<div id=\"single_banner_area2\" class=\"clearfix one_banner\">\n<div class=\"single_banner single_banner_left\">\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<!-- \u8a18\u4e8b\u4e2d(\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u5e83\u544a\u30e6\u30cb\u30c3\u30c8) -->\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block\"\r\n     data-ad-client=\"ca-pub-7306936664602087\"\r\n     data-ad-slot=\"5429724765\"\r\n     data-ad-format=\"auto\"\r\n     data-full-width-responsive=\"true\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\n<\/div>\n<div class=\"single_banner single_banner_right\">\n<a href=\"\" target=\"_blank\"><img decoding=\"async\" src=\"\" alt=\"\" title=\"\" \/><\/a>\n<\/div>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"\u8907\u6570\u306eExcel\u30d5\u30a1\u30a4\u30eb\u3092PDF\u306b\u4e00\u62ec\u5909\u63db\u3059\u308b\u5fc5\u8981\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u7c21\u5358\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002 Option Explicit Dim fp Dim fso Dim args Dim i Const msoFalse [&hellip;]","protected":false},"author":1,"featured_media":7132,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"\u30d1\u30b9\u30ef\u30fc\u30c9\u4ed8\u304d\u30d5\u30a1\u30a4\u30eb\u7b49\u306f\u8003\u616e\u3057\u306a\u3044\u7c21\u5358\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u3002 [\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3057\u305fOffice\u30d5\u30a1\u30a4\u30eb\u3092PDF\u306b\u5909\u63db\u3059\u308bVBScript]","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":[48,4,49,58,6],"tags":[],"class_list":["post-10256","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-excel-office","category-office","category-word-office","category-powerpoint","category-vbs"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-VBScript.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-2Fq","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10256","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=10256"}],"version-history":[{"count":1,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10256\/revisions"}],"predecessor-version":[{"id":10257,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10256\/revisions\/10257"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7132"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}