{"id":3828,"date":"2013-12-12T16:49:39","date_gmt":"2013-12-12T07:49:39","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=3828"},"modified":"2015-02-18T13:58:51","modified_gmt":"2015-02-18T04:58:51","slug":"office%e6%96%87%e6%9b%b8%e3%82%92%e6%97%a7%e3%83%90%e3%83%bc%e3%82%b8%e3%83%a7%e3%83%b3%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%8bvbscr","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=3828","title":{"rendered":"Office\u6587\u66f8\u3092\u65e7\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f\u306b\u5909\u63db\u3059\u308bVBScript"},"content":{"rendered":"<p>xlsx\u3084docx\u3068\u3044\u3063\u305f\u65b0\u3057\u3044\u5f62\u5f0f\u306eOffice\u6587\u66f8\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3059\u308b\u3068\u3001xls\u3084doc\u3068\u3044\u3063\u305f\u65e7\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f\u306b\u5909\u63db\u3057\u3066\u5143\u30d5\u30a1\u30a4\u30eb\u3068\u540c\u3058\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u51fa\u529b\u3059\u308bVBScript\u3067\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Option Explicit\r\n\r\nDim Fso\r\nDim Args\r\nDim OutputFilePath\r\nDim i\r\n\r\nConst wdFormatDocument = 0\r\nConst wdDoNotSaveChanges = 0\r\nConst xlNormal = -4143\r\nConst ppSaveAsPresentation = 1\r\n\r\nSet Fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)\r\nSet Args = WScript.Arguments\r\nIf Args.Count &lt; 1 Then\r\n  MsgBox &quot;\u65e7\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f\u306b\u5909\u63db\u3057\u305f\u3044Office\u6587\u66f8\u3092\u5f53\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;\r\n  WScript.Quit\r\nEnd If\r\n\r\n'\u30c9\u30ed\u30c3\u30d7\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u51e6\u7406(\u8907\u6570\u30d5\u30a1\u30a4\u30eb\u5bfe\u5fdc)\r\nOn Error Resume Next\r\nFor i = 0 To Args.Count - 1\r\n  '\u62e1\u5f35\u5b50\u306b\u3088\u3063\u3066\u51e6\u7406\u5206\u5c90\r\n  Select Case LCase(Fso.GetExtensionName(Args(i)))\r\n    'Word\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\r\n    Case &quot;docx&quot;, &quot;docm&quot;\r\n      OutputFilePath = Fso.GetParentFolderName(Args(i)) &amp; ChrW(92) &amp; Fso.GetBaseName(Args(i)) &amp; &quot;.doc&quot;\r\n      With CreateObject(&quot;Word.Application&quot;)\r\n        .Visible = True\r\n        .DisplayAlerts = False\r\n        With .Documents.Open(Args(i))\r\n          .SaveAs OutputFilePath, wdFormatDocument\r\n          .Close wdDoNotSaveChanges\r\n        End With\r\n        .DisplayAlerts = True\r\n        .Quit\r\n      End With\r\n    'Excel\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\r\n    Case &quot;xlsx&quot;, &quot;xlsm&quot;\r\n      OutputFilePath = Fso.GetParentFolderName(Args(i)) &amp; ChrW(92) &amp; Fso.GetBaseName(Args(i)) &amp; &quot;.xls&quot;\r\n      With CreateObject(&quot;Excel.Application&quot;)\r\n        .Visible = True\r\n        .DisplayAlerts = False\r\n        With .Workbooks.Open(Args(i))\r\n          .SaveAs OutputFilePath, xlNormal\r\n          .Close False\r\n        End With\r\n        .DisplayAlerts = True\r\n        .Quit\r\n      End With\r\n    'PowerPoint\u30d5\u30a1\u30a4\u30eb\u51e6\u7406\r\n    Case &quot;pptx&quot;, &quot;pptm&quot;\r\n      OutputFilePath = Fso.GetParentFolderName(Args(i)) &amp; ChrW(92) &amp; Fso.GetBaseName(Args(i)) &amp; &quot;.ppt&quot;\r\n      With CreateObject(&quot;PowerPoint.Application&quot;)\r\n        .Visible = True\r\n        .DisplayAlerts = False\r\n        With .Presentations.Open(Args(i))\r\n          .SaveAs OutputFilePath, ppSaveAsPresentation\r\n          .Close\r\n        End With\r\n        .DisplayAlerts = True\r\n        .Quit\r\n      End With\r\n  End Select\r\n  WScript.Sleep 500 '\u51e6\u7406\u5f85\u3061\r\nNext\r\nOn Error GoTo 0\r\n\r\nMsgBox &quot;\u51e6\u7406\u304c\u7d42\u4e86\u3057\u307e\u3057\u305f\u3002&quot;<\/pre>\n<p>5\u5e74\u304f\u3089\u3044\u524d\u306b\u66f8\u3044\u305f\u3082\u306e\u304c\u51fa\u3066\u304d\u305f\u306e\u3067\u3001\u5fd8\u308c\u306a\u3044\u3046\u3061\u306b\u30e1\u30e2\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<h4>\u25a0 \u95a2\u9023\u8a18\u4e8b<\/h4>\n<p><strong>\u30fb\u53e4\u3044\u5f62\u5f0f\u306eWord\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u65b0\u3057\u3044\u5f62\u5f0f\u306b\u4e00\u62ec\u5909\u63db\u3059\u308bVBScript<\/strong><br \/>\n<a href=\"\/\/www.ka-net.org\/blog\/?p=3427\" title=\"\u53e4\u3044\u5f62\u5f0f\u306eWord\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u65b0\u3057\u3044\u5f62\u5f0f\u306b\u4e00\u62ec\u5909\u63db\u3059\u308bVBScript | \u521d\u5fc3\u8005\u5099\u5fd8\u9332\" target=\"_blank\">\/\/www.ka-net.org\/blog\/?p=3427<\/a><br \/>\n<strong>\u30fb\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3067Excel\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c9\u30a4\u30f3\u5f62\u5f0f(xlam)\u306b\u4e00\u62ec\u5909\u63db\u3059\u308bVBScript<\/strong><br \/>\n<a href=\"\/\/www.ka-net.org\/blog\/?p=5264\" title=\"\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3067Excel\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c9\u30a4\u30f3\u5f62\u5f0f(xlam)\u306b\u4e00\u62ec\u5909\u63db\u3059\u308bVBScript | \u521d\u5fc3\u8005\u5099\u5fd8\u9332\" target=\"_blank\">\/\/www.ka-net.org\/blog\/?p=5264<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"xlsx\u3084docx\u3068\u3044\u3063\u305f\u65b0\u3057\u3044\u5f62\u5f0f\u306eOffice\u6587\u66f8\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3059\u308b\u3068\u3001xls\u3084doc\u3068\u3044\u3063\u305f\u65e7\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f\u306b\u5909\u63db\u3057\u3066\u5143\u30d5\u30a1\u30a4\u30eb\u3068\u540c\u3058\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u51fa\u529b\u3059\u308bVBScript\u3067\u3059\u3002  [&hellip;]","protected":false},"author":1,"featured_media":7132,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[6],"tags":[],"class_list":["post-3828","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","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-ZK","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3828","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=3828"}],"version-history":[{"count":2,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3828\/revisions"}],"predecessor-version":[{"id":5267,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3828\/revisions\/5267"}],"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=3828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}