{"id":7293,"date":"2016-09-09T10:29:46","date_gmt":"2016-09-09T01:29:46","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=7293"},"modified":"2016-09-09T10:29:46","modified_gmt":"2016-09-09T01:29:46","slug":"pdf%e3%82%92%e5%88%86%e5%89%b2%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=7293","title":{"rendered":"PDF\u3092\u5206\u5272\u3059\u308bVBA\u30de\u30af\u30ed"},"content":{"rendered":"<p>\u300c<span style=\"color: #ff0000; font-weight: bold;\">VBA PDF \u5206\u5272<\/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\u3092\u5206\u5272\u3059\u308b\u65b9\u6cd5\u3092\u63a2\u3057\u3066\u3044\u308b\u65b9\u3060\u308d\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u524d\u3001\u4e0b\u8a18\u8a18\u4e8b\u3067PDF\u30d5\u30a1\u30a4\u30eb\u3092\u7d50\u5408\u3059\u308b\u30de\u30af\u30ed\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u306f\u9006\u306b\u3001Acrobat\u3092\u4f7f\u3063\u3066PDF\u30d5\u30a1\u30a4\u30eb\u3092\u5206\u5272\u3059\u308b\u30de\u30af\u30ed\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<div class=\"cardlink\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=5866\"><div class=\"cardlink_thumbnail\"><img src='https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Acrobat-120x120.png' alt='Acrobat\u3092\u4f7f\u3063\u3066PDF\u30d5\u30a1\u30a4\u30eb\u3092\u7d50\u5408\u3059\u308bVBA\u30de\u30af\u30ed' width=120 height=120 \/><\/a><\/div><div class=\"cardlink_content\"><span class=\"timestamp\">2015.07.22<\/span><div class=\"cardlink_title\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=5866\">Acrobat\u3092\u4f7f\u3063\u3066PDF\u30d5\u30a1\u30a4\u30eb\u3092\u7d50\u5408\u3059\u308bVBA\u30de\u30af\u30ed <\/a><\/div><div class=\"cardlink_excerpt\">\u524d\u56de\u306e\u8a18\u4e8b\u3067\u306f\u3001iTextSharp\u3092\u4f7f\u3063\u3066PDF\u30d5\u30a1\u30a4\u30eb\u3092\u7d50\u5408\u3059\u308bPowerShell\u30b3\u30fc\u30c9\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u306fAcrobat\u3092\u4f7f\u3063\u3066PDF\u30d5\u30a1\u30a4\u30eb\u3092\u7d50\u5408\u3059\u308bVBA\u30de\u30af\u30ed\u3092\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\r\n\r\n\r\n[vb]Option Explicit\r\n\r\nP...<\/div><\/div><div class=\"cardlink_footer\"><\/div><\/div>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Option Explicit\r\n\r\nPublic Sub Sample()\r\n  Dim jso As Object\r\n  Dim i As Long\r\n  Dim fp As String, fn As String\r\n  Const PdfFilePath = &quot;C:\\Test\\PDF\\Test.pdf&quot;\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(PdfFilePath))\r\n    fn = .GetBaseName(PdfFilePath)\r\n  End With\r\n  \r\n  With CreateObject(&quot;AcroExch.PDDoc&quot;)\r\n    If .Open(PdfFilePath) = True Then\r\n      Set jso = .GetJSObject\r\n      For i = 0 To .GetNumPages() - 1\r\n        '\u5143\u306ePDF\u30d5\u30a1\u30a4\u30eb\u3068\u540c\u3058\u5834\u6240\u306b\u30da\u30fc\u30b8\u756a\u53f7\u3092\u4ed8\u3051\u3066\u4fdd\u5b58\r\n        CallByName jso, &quot;extractPages&quot;, VbMethod, _\r\n                   i, i, fp &amp; fn &amp; &quot;(&quot; &amp; i + 1 &amp; &quot;).pdf&quot;\r\n      Next\r\n      .Close\r\n    End If\r\n  End With\r\nEnd Sub\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>Acrobat JavaScript\u306eDoc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u306f\u30da\u30fc\u30b8\u3092\u5206\u5272\u3059\u308b\u305f\u3081\u306e<span style=\"color: #ff0000; font-weight: bold;\">extractPages<\/span>\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\u308b\u308f\u3051\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u300cVBA PDF \u5206\u5272\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\u3092\u5206\u5272\u3059\u308b\u65b9\u6cd5\u3092\u63a2\u3057\u3066\u3044\u308b\u65b9\u3060\u308d\u3046\u3068\u601d\u3044\u307e\u3059\u3002 \u4ee5\u524d\u3001\u4e0b\u8a18\u8a18\u4e8b\u3067PDF\u30d5\u30a1\u30a4\u30eb\u3092\u7d50\u5408\u3059\u308b\u30de\u30af\u30ed\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u306f\u9006\u306b\u3001 [&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":"VBA\u304b\u3089PDF\u30d5\u30a1\u30a4\u30eb\u3092\u51e6\u7406\u3059\u308b\u5834\u5408\u3001\u3084\u306f\u308aAcrobat\u3092\u4f7f\u3046\u306e\u304c\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 [PDF\u3092\u5206\u5272\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-7293","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-1TD","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7293","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=7293"}],"version-history":[{"count":1,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7293\/revisions"}],"predecessor-version":[{"id":7294,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7293\/revisions\/7294"}],"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=7293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}