{"id":2337,"date":"2012-10-18T17:04:20","date_gmt":"2012-10-18T08:04:20","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=2337"},"modified":"2012-10-18T17:04:20","modified_gmt":"2012-10-18T08:04:20","slug":"adobe-reader-xi%e3%82%92%e5%88%a9%e7%94%a8%e3%81%97%e3%81%a6pdf%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e3%83%9a%e3%83%bc%e3%82%b8%e6%95%b0%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8bvba","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=2337","title":{"rendered":"Adobe Reader XI\u3092\u5229\u7528\u3057\u3066PDF\u30d5\u30a1\u30a4\u30eb\u306e\u30da\u30fc\u30b8\u6570\u3092\u53d6\u5f97\u3059\u308bVBA\u30de\u30af\u30ed"},"content":{"rendered":"<p>\u5148\u65e5<a href=\"\/\/www.ka-net.org\/blog\/?p=2314\" title=\"Adobe Reader\u3092\u5229\u7528\u3057\u3066PDF\u30d5\u30a1\u30a4\u30eb\u306e\u30da\u30fc\u30b8\u6570\u3092\u53d6\u5f97\u3059\u308bVBA\u30de\u30af\u30ed\" target=\"_blank\">Adobe Reader\u3092\u5229\u7528\u3057\u3066PDF\u30d5\u30a1\u30a4\u30eb\u306e\u30da\u30fc\u30b8\u6570\u3092\u53d6\u5f97\u3059\u308bVBA\u30de\u30af\u30ed<\/a>\u306b\u3064\u3044\u3066\u8a18\u4e8b\u3092\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u30bf\u30a4\u30df\u30f3\u30b0\u3088\u304f\u300c<span style=\"color: #ff0000; font-weight: bold;\">Adobe Reader XI<\/span>\u300d\u304c\u516c\u958b\u3055\u308c\u307e\u3057\u305f\u306e\u3067\u3001XI\u7528\u306b\u30de\u30af\u30ed\u3092\u4fee\u6b63\u3057\u3066\u307f\u307e\u3057\u305f(\u3068\u3044\u3063\u3066\u3082\u30e1\u30cb\u30e5\u30fcID\u3092\u76f4\u3057\u305f\u3060\u3051\u3067\u3059\u304c\u2026)\u3002<\/p>\n<p><!--more--><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">'\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\r\n'\u203b Adobe Reader XI\u74b0\u5883\u3067\u5b9f\u884c\r\n'\u203b \u305d\u306e\u4ed6\u74b0\u5883\u3067\u306f\u52d5\u4f5c\u3057\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\r\nOption Explicit\r\n\r\nPrivate Declare Function EnumChildWindows Lib &quot;user32&quot; (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, lParam As Long) As Long\r\nPrivate Declare Function FindWindowEx Lib &quot;user32&quot; Alias &quot;FindWindowExA&quot; (ByVal hWndParent As Long, ByVal hWndChildAfter As Long, ByVal lpszClass As String, ByVal lpszWindow As String) As Long\r\nPrivate Declare Function GetClassName Lib &quot;user32&quot; Alias &quot;GetClassNameA&quot; (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long\r\nPrivate Declare Function GetWindow Lib &quot;user32&quot; (ByVal hWnd As Long, ByVal wCmd As Long) As Long\r\nPrivate Declare Function GetWindowText Lib &quot;user32&quot; Alias &quot;GetWindowTextA&quot; (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long\r\nPrivate Declare Function PostMessage Lib &quot;user32&quot; Alias &quot;PostMessageA&quot; (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long\r\nPrivate Declare Function SendMessage Lib &quot;user32&quot; Alias &quot;SendMessageA&quot; (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long\r\nPrivate Declare Sub Sleep Lib &quot;kernel32&quot; (ByVal dwMilliseconds As Long)\r\n\r\nPrivate Const GW_HWNDNEXT As Long = 2\r\nPrivate Const TCM_SETCURFOCUS As Long = &amp;H1330\r\nPrivate Const WM_COMMAND As Long = &amp;H111\r\nPrivate Const AppPath As String = &quot;C:\\Program Files\\Adobe\\Reader 11.0\\Reader\\AcroRd32.exe&quot; 'Adobe Reader\u306e\u30d1\u30b9\r\nPrivate hPage As Long\r\n\r\nPublic Sub Sample()\r\n  Dim num As Long\r\n  \r\n  num = GetPDFPages(&quot;C:\\Test&#92;&#48;01.pdf&quot;)\r\n  If num = 0&amp; Then\r\n    Debug.Print &quot;Err.&quot;\r\n  Else\r\n    Debug.Print &quot;\u30da\u30fc\u30b8\u6570:&quot; &amp; num\r\n  End If\r\nEnd Sub\r\n\r\nPublic Function GetPDFPages(ByVal PdfPath As String) As Long\r\n  Dim hApp As Long, hDlg As Long, hTab As Long, hPageNum As Long\r\n  Dim cmd As String\r\n  Dim winName As String\r\n  Dim buf As String * 255\r\n  Dim ret As Long\r\n  Dim timeLimit As Date\r\n  \r\n  ret = 0&amp; '\u521d\u671f\u5316\r\n  cmd = &quot;&quot;&quot;&quot; &amp; AppPath &amp; &quot;&quot;&quot;&quot; &amp; &quot; &quot; &amp; &quot;&quot;&quot;&quot; &amp; PdfPath &amp; &quot;&quot;&quot;&quot;\r\n  Shell cmd, vbNormalFocus 'Adobe Reader\u8d77\u52d5\r\n  'CreateObject(&quot;Shell.Application&quot;).ShellExecute &quot;&quot;&quot;&quot; &amp; PdfPath &amp; &quot;&quot;&quot;&quot; '\u95a2\u9023\u4ed8\u3051\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306f\u3053\u3061\u3089\u3067\u3082\u53ef\r\n  timeLimit = DateAdd(&quot;s&quot;, 5, Now()) '\u30eb\u30fc\u30d7\u306e\u5236\u9650\u6642\u9593:5\u79d2\r\n  Do\r\n    hApp = FindWindowEx(0&amp;, 0&amp;, &quot;AcrobatSDIWindow&quot;, vbNullString)\r\n    Sleep 500&amp;\r\n    DoEvents\r\n    If Now() &gt; timeLimit Then Exit Do '\u5236\u9650\u6642\u9593\u3092\u904e\u304e\u305f\u3089\u30eb\u30fc\u30d7\u3092\u629c\u3051\u308b\r\n  Loop While hApp = 0&amp;\r\n  If hApp = 0&amp; Then GoTo Err\r\n  PostMessage hApp, WM_COMMAND, &amp;H1788, 0&amp; '\u6587\u66f8\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u8868\u793a\r\n  timeLimit = DateAdd(&quot;s&quot;, 5, Now()) '\u30eb\u30fc\u30d7\u306e\u5236\u9650\u6642\u9593:5\u79d2\r\n  Do\r\n    hDlg = FindWindowEx(0&amp;, 0&amp;, &quot;#32770&quot;, &quot;\u6587\u66f8\u306e\u30d7\u30ed\u30d1\u30c6\u30a3&quot;)\r\n    Sleep 500&amp;\r\n    DoEvents\r\n    If Now() &gt; timeLimit Then Exit Do '\u5236\u9650\u6642\u9593\u3092\u904e\u304e\u305f\u3089\u30eb\u30fc\u30d7\u3092\u629c\u3051\u308b\r\n  Loop While hDlg = 0&amp;\r\n  If hDlg = 0&amp; Then GoTo Err\r\n  hTab = FindWindowEx(hDlg, 0&amp;, &quot;GroupBox&quot;, vbNullString)\r\n  hTab = FindWindowEx(hTab, 0&amp;, &quot;SysTabControl32&quot;, vbNullString)\r\n  If hTab = 0&amp; Then GoTo Err\r\n  SendMessage hTab, TCM_SETCURFOCUS, 0&amp;, 0&amp; '\u300c\u6982\u8981\u300d\u30bf\u30d6\u9078\u629e\r\n  EnumChildWindows hDlg, AddressOf EnumChildProc, 0&amp;\r\n  If hPage = 0&amp; Then GoTo Err\r\n  hPageNum = GetWindow(hPage, GW_HWNDNEXT)\r\n  If hPageNum = 0&amp; Then GoTo Err\r\n  If GetWindowText(hPageNum, buf, Len(buf)) = 0&amp; Then GoTo Err\r\n  winName = Left$(buf, InStr(buf, vbNullChar) - 1)\r\n  ret = CLng(winName)\r\n  SendMessage hDlg, WM_COMMAND, vbOK, 0&amp; '\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u9589\u3058\u308b\r\n  SendMessage hApp, WM_COMMAND, &amp;H1791, 0&amp; '\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u7d42\u4e86\r\nErr:\r\n  GetPDFPages = ret\r\nEnd Function\r\n\r\nPrivate Function EnumChildProc(ByVal hWnd As Long, ByVal lParam As Long) As Long\r\n  Dim clsName As String, winName As String\r\n  Dim buf1 As String * 255, buf2 As String * 255\r\n  \r\n  If GetClassName(hWnd, buf1, Len(buf1)) &lt;&gt; 0&amp; Then\r\n    clsName = Left$(buf1, InStr(buf1, vbNullChar) - 1)\r\n    If clsName = &quot;Static&quot; Then\r\n      If GetWindowText(hWnd, buf2, Len(buf2)) &lt;&gt; 0&amp; Then\r\n        winName = Left$(buf2, InStr(buf2, vbNullChar) - 1)\r\n        If winName = &quot;\u30da\u30fc\u30b8\u6570 :&quot; Then\r\n          hPage = hWnd\r\n          EnumChildProc = False\r\n          Exit Function\r\n        End If\r\n      End If\r\n    End If\r\n  End If\r\n  EnumChildProc = True\r\nEnd Function<\/pre>\n<p>\u4e00\u5fdc&#8221;<strong>PDF\u30d5\u30a1\u30a4\u30eb\u306e\u30da\u30fc\u30b8\u6570\u3092\u53d6\u5f97\u3059\u308b<\/strong>&#8220;\u3068\u3044\u3046\u76ee\u7684\u306f\u9054\u6210\u3067\u304d\u307e\u3059\u304c\u3001\u3084\u306f\u308a\u7121\u7406\u3084\u308a\u611f\u306f\u5426\u3081\u306a\u3044\u3067\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5148\u65e5Adobe Reader\u3092\u5229\u7528\u3057\u3066PDF\u30d5\u30a1\u30a4\u30eb\u306e\u30da\u30fc\u30b8\u6570\u3092\u53d6\u5f97\u3059\u308bVBA\u30de\u30af\u30ed\u306b\u3064\u3044\u3066\u8a18\u4e8b\u3092\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u30bf\u30a4\u30df\u30f3\u30b0\u3088\u304f\u300cAdobe Reader XI\u300d\u304c\u516c\u958b\u3055\u308c\u307e\u3057\u305f\u306e\u3067\u3001XI\u7528\u306b\u30de\u30af\u30ed\u3092\u4fee\u6b63\u3057\u3066\u307f\u307e\u3057\u305f(\u3068\u3044 [&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,49],"tags":[8,92,93],"class_list":["post-2337","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-excel-office","category-word-office","tag-vba","tag-adobe-reader","tag-pdf"],"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-BH","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2337","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=2337"}],"version-history":[{"count":2,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2337\/revisions"}],"predecessor-version":[{"id":2339,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2337\/revisions\/2339"}],"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=2337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}