{"id":4054,"date":"2014-02-24T13:21:59","date_gmt":"2014-02-24T04:21:59","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=4054"},"modified":"2021-09-29T22:52:07","modified_gmt":"2021-09-29T13:52:07","slug":"pdf%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ab%e5%b7%ae%e3%81%97%e8%be%bc%e3%81%bf%e5%8d%b0%e5%88%b7%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=4054","title":{"rendered":"PDF\u30d5\u30a1\u30a4\u30eb\u306b\u5dee\u3057\u8fbc\u307f\u5370\u5237\u3059\u308bVBA\u30de\u30af\u30ed"},"content":{"rendered":"<p><a href=\"http:\/\/kb2.adobe.com\/jp\/cps\/510\/510087.html\" title=\"ActiveX\u30aa\u30fc\u30c8\u30e1\u30fc\u30b7\u30e7\u30f3\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3068\u306a\u308b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089Acrobat\u3092\u53c2\u7167\u3059\u308b\u306b\u306f\" target=\"_blank\" rel=\"noopener\">\u3053\u306e\u30da\u30fc\u30b8<\/a>\u306b\u3082\u3042\u308b\u3088\u3046\u306b\u3001Acrobat\u306fOLE\u30aa\u30fc\u30c8\u30e1\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u306b\u3088\u3063\u3066VBA\u30de\u30af\u30ed\u304b\u3089\u64cd\u4f5c\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306fWord\u306e\u5dee\u3057\u8fbc\u307f\u5370\u5237\u6a5f\u80fd\u306e\u3088\u3046\u306b\u3001\u6307\u5b9a\u3057\u305fPDF\u30d5\u30a1\u30a4\u30eb\u306e\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30fc\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u306b\u5024\u3092\u5dee\u3057\u8fbc\u3080\u51e6\u7406\u3092\u8003\u3048\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u5bfe\u8c61\u3068\u306a\u308bPDF\u30d5\u30a1\u30a4\u30eb\u306b\u306f\u4e0b\u56f3\u306e\u3088\u3046\u306b\u6c0f\u540d(<span style=\"color: #ff0000; font-weight: bold;\">\u30d5\u30a3\u30fc\u30eb\u30c9\u540d:fldName<\/span>)\u3001\u5e74\u9f62(<span style=\"color: #ff0000; font-weight: bold;\">\u30d5\u30a3\u30fc\u30eb\u30c9\u540d:fldAge<\/span>)\u3001\u4f4f\u6240(<span style=\"color: #ff0000; font-weight: bold;\">\u30d5\u30a3\u30fc\u30eb\u30c9\u540d:fldAddress<\/span>)\u306e3\u3064\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u3042\u308a\u3001<\/p>\n<p><a href=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/AcrobatAutomation_01_01.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/AcrobatAutomation_01_01.jpg\" alt=\"AcrobatAutomation_01_01\" width=\"820\" height=\"219\" class=\"alignnone size-full wp-image-4055\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/AcrobatAutomation_01_01.jpg 820w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/AcrobatAutomation_01_01-300x80.jpg 300w\" sizes=\"auto, (max-width: 820px) 100vw, 820px\" \/><\/a><\/p>\n<p>\u4e0b\u56f3\u306e\u3088\u3046\u306a\u30bb\u30ebA2 &#8211; C6\u307e\u3067\u306e\u5024\u3092\u5dee\u3057\u8fbc\u3080\u3053\u3068\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/AcrobatAutomation_01_02.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/AcrobatAutomation_01_02.jpg\" alt=\"AcrobatAutomation_01_02\" width=\"576\" height=\"144\" class=\"alignnone size-full wp-image-4056\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/AcrobatAutomation_01_02.jpg 576w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/AcrobatAutomation_01_02-300x75.jpg 300w\" sizes=\"auto, (max-width: 576px) 100vw, 576px\" \/><\/a><\/p>\n<p>\u65e9\u901f\u8003\u3048\u305f\u30b3\u30fc\u30c9\u304c\u4e0b\u8a18\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #ff0000; font-weight: bold;\">\u203b \u52d5\u4f5c\u78ba\u8a8d\u306fWindows 7 + Acrobat XI\u74b0\u5883\u3067\u884c\u3044\u307e\u3057\u305f\u3002<\/span><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Option Explicit\r\n\r\nPublic Sub Sample()\r\n  Dim app As Object\r\n  Dim avdoc As Object\r\n  Dim i As Long\r\n  Const PdfFilePath As String = &quot;C:\\Files\\template.pdf&quot; 'PDF\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\r\n  \r\n  Set app = CreateObject(&quot;AcroExch.App&quot;)\r\n  Set avdoc = CreateObject(&quot;AcroExch.AVDoc&quot;)\r\n  If avdoc.Open(PdfFilePath, &quot;&quot;) = True Then\r\n    app.Show 'Acrobat\u8868\u793a\r\n    With avdoc.GetPDDoc.GetJSObject\r\n      For i = 2 To ActiveSheet.Range(&quot;A1&quot;).End(xlDown).Row\r\n        .getField(&quot;fldName&quot;).Value = CStr(ActiveSheet.Cells(i, 1).Value)\r\n        .getField(&quot;fldAge&quot;).Value = CStr(ActiveSheet.Cells(i, 2).Value)\r\n        .getField(&quot;fldAddress&quot;).Value = CStr(ActiveSheet.Cells(i, 3).Value)\r\n        avdoc.PrintPages 0, 0, 3, 0, 0 '1\u30da\u30fc\u30b8\u76ee\u3060\u3051\u3092\u901a\u5e38\u4f7f\u3046\u30d7\u30ea\u30f3\u30bf\u30fc\u3067\u5370\u5237\r\n      Next\r\n    End With\r\n    avdoc.Close 1 '\u6587\u66f8\u3092\u4fdd\u5b58\u305b\u305a\u306b\u9589\u3058\u308b\r\n    app.Hide: app.Exit\r\n  End If\r\nEnd Sub<\/pre>\n<p>\u4e0a\u8a18\u30b3\u30fc\u30c9\u306f\u3001<\/p>\n<ol>\n<li>CAcroAVDoc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306eOpen\u30e1\u30bd\u30c3\u30c9\u3067\u300c<em>C:\\Files\\template.pdf<\/em>\u300d\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304d\u307e\u3059\u3002<\/li>\n<li>GetPDDoc\u30e1\u30bd\u30c3\u30c9\u3067\u53d6\u5f97\u3057\u305fCAcroPDDoc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306eGetJSObject\u30e1\u30bd\u30c3\u30c9\u306b\u3088\u3063\u3066JSObject\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/li>\n<li>JSObject\u7d4c\u7531\u3067Doc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8(Acrobat)\u306egetField\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u5404\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u53d6\u5f97\u3001\u5024\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>CAcroAVDoc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306ePrintPages\u30e1\u30bd\u30c3\u30c9\u30671\u30da\u30fc\u30b8\u76ee\u3060\u3051\u901a\u5e38\u4f7f\u3046\u30d7\u30ea\u30f3\u30bf\u30fc\u3067\u5370\u5237\u3057\u307e\u3059\u3002<\/li>\n<li>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u305b\u305a\u306b\u9589\u3058\u3001Acrobat\u3092\u7d42\u4e86\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n<p>\u3068\u3044\u3063\u305f\u51e6\u7406\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u5370\u5237\u305b\u305a\u3001\u5225\u540d\u3067PDF\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3059\u308b\u5834\u5408\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Public Sub Sample2()\r\n  Dim app As Object\r\n  Dim avdoc As Object\r\n  Dim pddoc As Object\r\n  Dim i As Long\r\n  Const PDSaveFull = 1\r\n  Const PdfFilePath As String = &quot;C:\\Files\\template.pdf&quot; 'PDF\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\r\n  \r\n  Set app = CreateObject(&quot;AcroExch.App&quot;)\r\n  Set avdoc = CreateObject(&quot;AcroExch.AVDoc&quot;)\r\n  If avdoc.Open(PdfFilePath, &quot;&quot;) = True Then\r\n    app.Show 'Acrobat\u8868\u793a\r\n    Set pddoc = avdoc.GetPDDoc\r\n    With pddoc.GetJSObject\r\n      For i = 2 To ActiveSheet.Range(&quot;A1&quot;).End(xlDown).Row\r\n        .getField(&quot;fldName&quot;).Value = CStr(ActiveSheet.Cells(i, 1).Value)\r\n        .getField(&quot;fldAge&quot;).Value = CStr(ActiveSheet.Cells(i, 2).Value)\r\n        .getField(&quot;fldAddress&quot;).Value = CStr(ActiveSheet.Cells(i, 3).Value)\r\n        pddoc.Save PDSaveFull, &quot;C:\\Files\\MyPDF_&quot; &amp; i - 1 &amp; &quot;.pdf&quot; 'PDF\u30d5\u30a1\u30a4\u30eb\u3092\u5225\u540d\u4fdd\u5b58\r\n      Next\r\n    End With\r\n    avdoc.Close 1 '\u6587\u66f8\u3092\u4fdd\u5b58\u305b\u305a\u306b\u9589\u3058\u308b\r\n    app.Hide: app.Exit\r\n  End If\r\nEnd Sub<\/pre>\n<p>\u4e0a\u8a18\u30b3\u30fc\u30c9\u3067\u4f7f\u3063\u3066\u3044\u308bAcrobat\u306e\u5404\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3084\u30e1\u30bd\u30c3\u30c9\u306b\u95a2\u3059\u308b\u8aac\u660e\u306f\u3001<a href=\"http:\/\/www.adobe.com\/jp\/devnet\/acrobat\/interapplication_communication.html\" title=\"Interapplication communication | Adobe Acrobat Developer Center\" target=\"_blank\" rel=\"noopener\">\u516c\u5f0f\u30b5\u30a4\u30c8\u306e\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/a>\u3092\u53c2\u8003\u306b\u3057\u3066\u3082\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u65e5\u672c\u8a9e\u306e\u60c5\u5831\u6e90\u3068\u3057\u3066\u306f\u4e0b\u8a18\u30b5\u30a4\u30c8\u3092\u53c2\u7167\u3059\u308b\u3053\u3068\u3092\u304a\u85a6\u3081\u3057\u307e\u3059\u3002<br \/>\nVBA\u304b\u3089\u306eAcrobat\u30aa\u30fc\u30c8\u30e1\u30fc\u30b7\u30e7\u30f3\u306b\u95a2\u3057\u3066\u306f\u3001\u4e0b\u8a18\u30b5\u30a4\u30c8\u304c\u6700\u3082\u5145\u5b9f\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong>\u30fbPDF<\/strong><br \/>\n<a href=\"http:\/\/pdf-file.nnn2.com\/\" title=\"PDF\" target=\"_blank\" rel=\"noopener\">http:\/\/pdf-file.nnn2.com\/<\/a><\/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<h4 class=\"style4a\">\u95a2\u9023\u8a18\u4e8b<\/h4>\n<div class=\"cardlink\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=6637\"><div class=\"cardlink_thumbnail\"><img src='https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Excel-120x120.png' alt='PDF\u30d5\u30a1\u30a4\u30eb\u4e0a\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u5024\u3092\u64cd\u4f5c\u3059\u308bVBA\u30de\u30af\u30ed' width=120 height=120 \/><\/a><\/div><div class=\"cardlink_content\"><span class=\"timestamp\">2016.02.03<\/span><div class=\"cardlink_title\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=6637\">PDF\u30d5\u30a1\u30a4\u30eb\u4e0a\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u5024\u3092\u64cd\u4f5c\u3059\u308bVBA\u30de\u30af\u30ed <\/a><\/div><div class=\"cardlink_excerpt\">\u300cPDF\u30d5\u30a1\u30a4\u30eb\u306b\u5dee\u3057\u8fbc\u307f\u5370\u5237\u3059\u308bVBA\u30de\u30af\u30ed\u300d\u3067\u3001Acrobat\u3092\u64cd\u4f5c\u3057\u3066PDF\u4e0a\u306e\u30d5\u30a9\u30fc\u30e0\u306b\u30c7\u30fc\u30bf\u3092\u5dee\u3057\u8fbc\u3080\u30de\u30af\u30ed\u3092\u7d39\u4ecb\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u201c\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u306b\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u308b\u306b\u306f\u3069\u3046\u3057\u305f\u3089\u826f\u3044\u304b\uff1f\u201d\u3001\u3068\u3044\u3046\u8cea\u554f\u304c\u3042\u308a\u307e\u3057\u305f\u3002\r\n\r\n\u7b54\u3048\u306f\u7c21\u5358\u3067\u3001getFi...<\/div><\/div><div class=\"cardlink_footer\"><\/div><\/div>\n<div class=\"cardlink\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=14124\"><div class=\"cardlink_thumbnail\"><img src='https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Acrobat-120x120.png' alt='PDF\u30d5\u30a1\u30a4\u30eb\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8aad\u307f\u53d6\u308a\u5c02\u7528\u306b\u3059\u308bVBA\u30de\u30af\u30ed' width=120 height=120 \/><\/a><\/div><div class=\"cardlink_content\"><span class=\"timestamp\">2021.09.29<\/span><div class=\"cardlink_title\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=14124\">PDF\u30d5\u30a1\u30a4\u30eb\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8aad\u307f\u53d6\u308a\u5c02\u7528\u306b\u3059\u308bVBA\u30de\u30af\u30ed <\/a><\/div><div class=\"cardlink_excerpt\">\u300cPDF\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306b\u5024\u3092\u5165\u529b\u3057\u305f\u5f8c\u3001\u8aad\u307f\u53d6\u308a\u5c02\u7528\u306b\u3059\u308b\u306b\u306f\u3069\u3046\u3057\u305f\u3089\u826f\u3044\u304b\uff1f\u300d\u3001\u3068\u3044\u3046\u8cea\u554f\u3092\u9802\u304d\u307e\u3057\u305f\u3002\r\n\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u64cd\u4f5c\u3059\u308b\u30de\u30af\u30ed\u306b\u3064\u3044\u3066\u306f\u3001\u4f55\u5e74\u304b\u524d\u306b\u8a18\u4e8b\u3092\u66f8\u3044\u3066\u3044\u307e\u3059\u3002\r\n\r\n\r\n\r\n\r\n\r\nAcrobat JavaScript\u306eField\u30aa\u30d6\u30b8\u30a7\u30af...<\/div><\/div><div class=\"cardlink_footer\"><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"\u3053\u306e\u30da\u30fc\u30b8\u306b\u3082\u3042\u308b\u3088\u3046\u306b\u3001Acrobat\u306fOLE\u30aa\u30fc\u30c8\u30e1\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u306b\u3088\u3063\u3066VBA\u30de\u30af\u30ed\u304b\u3089\u64cd\u4f5c\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002 \u4eca\u56de\u306fWord\u306e\u5dee\u3057\u8fbc\u307f\u5370\u5237\u6a5f\u80fd\u306e\u3088\u3046\u306b\u3001\u6307\u5b9a\u3057\u305fPDF\u30d5\u30a1\u30a4\u30eb\u306e\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30fc\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u306b\u5024\u3092\u5dee\u3057 [&hellip;]","protected":false},"author":1,"featured_media":7111,"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":[4,48,136],"tags":[],"class_list":["post-4054","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-excel-office","category-acrobat"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Excel.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-13o","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4054","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=4054"}],"version-history":[{"count":5,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4054\/revisions"}],"predecessor-version":[{"id":14128,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4054\/revisions\/14128"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7111"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}