{"id":8654,"date":"2017-07-03T12:15:58","date_gmt":"2017-07-03T03:15:58","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=8654"},"modified":"2017-07-03T14:39:18","modified_gmt":"2017-07-03T05:39:18","slug":"%e3%83%9a%e3%83%bc%e3%82%b8%e7%95%aa%e5%8f%b7%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8bword%e3%83%9e%e3%82%af%e3%83%ad","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=8654","title":{"rendered":"\u30da\u30fc\u30b8\u756a\u53f7\u3092\u53d6\u5f97\u3059\u308bWord\u30de\u30af\u30ed"},"content":{"rendered":"<p>Word\u30de\u30af\u30ed\u3067\u9078\u629e\u4f4d\u7f6e\u306e\u30da\u30fc\u30b8\u756a\u53f7\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3001\u7c21\u5358\u306a\u306e\u306fSelection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306eInformation\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u3046\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Public Sub Sample01()\r\n  With Selection\r\n    MsgBox &quot;\u6307\u5b9a\u3057\u305f\u9078\u629e\u7bc4\u56f2\u307e\u305f\u306f\u6307\u5b9a\u7bc4\u56f2\u306e\u7d42\u4e86\u4f4d\u7f6e\u306e\u30da\u30fc\u30b8\u756a\u53f7\uff1a&quot; &amp; _\r\n           .Information(wdActiveEndPageNumber) &amp; vbNewLine &amp; _\r\n           &quot;\u624b\u52d5\u3067\u5909\u66f4\u3057\u305f\u30da\u30fc\u30b8\u756a\u53f7\u3092\u53cd\u6620\uff1a&quot; &amp; _\r\n           .Information(wdActiveEndAdjustedPageNumber) &amp; vbNewLine &amp; _\r\n           &quot;\u7dcf\u30da\u30fc\u30b8\u6570\uff1a&quot; &amp; _\r\n           .Information(wdNumberOfPagesInDocument)\r\n  End With\r\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Word_VBA_PageNumber_01.jpg\" alt=\"\" width=\"858\" height=\"619\" class=\"alignnone size-full wp-image-8655\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Word_VBA_PageNumber_01.jpg 858w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Word_VBA_PageNumber_01-300x216.jpg 300w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Word_VBA_PageNumber_01-768x554.jpg 768w\" sizes=\"auto, (max-width: 858px) 100vw, 858px\" \/><\/p>\n<p>Information\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5f15\u6570(WdInformation)\u306b\u3088\u308b\u9055\u3044\u306f\u4e0b\u8a18\u306e\u901a\u308a\u3067\u3001\u72b6\u6cc1\u306b\u5fdc\u3058\u3066\u4f7f\u3044\u5206\u3051\u3092\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>wdActiveEndPageNumber\uff1a\u6307\u5b9a\u3057\u305f\u9078\u629e\u7bc4\u56f2\u307e\u305f\u306f\u6307\u5b9a\u7bc4\u56f2\u306e\u7d42\u4e86\u4f4d\u7f6e\u306e\u30da\u30fc\u30b8\u756a\u53f7\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/li>\n<li>wdActiveEndAdjustedPageNumber\uff1a\u6307\u5b9a\u3057\u305f\u9078\u629e\u7bc4\u56f2\u307e\u305f\u306f\u6307\u5b9a\u7bc4\u56f2\u306e\u7d42\u4e86\u4f4d\u7f6e\u306e\u30da\u30fc\u30b8\u756a\u53f7\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u533a\u5207\u3063\u3066\u624b\u52d5\u3067\u30da\u30fc\u30b8\u756a\u53f7\u3092\u632f\u308a\u76f4\u3057\u305f\u5834\u5408\u306f\u3001\u5909\u66f4\u5f8c\u306e\u30da\u30fc\u30b8\u756a\u53f7\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/li>\n<li>wdNumberOfPagesInDocument\uff1a\u7dcf\u30da\u30fc\u30b8\u6570\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<p>\u5148\u65e5\u3001MSDN\u30d5\u30a9\u30fc\u30e9\u30e0\u306b\u300c<a href=\"https:\/\/social.msdn.microsoft.com\/Forums\/ja-JP\/vbajp\/thread\/379b8219-8acc-4f81-96f5-e4c3f81aef2f\" title=\"Word VBA\u3067\uff0c\u73fe\u5728\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u30da\u30fc\u30b8\u306e\u30da\u30fc\u30b8\u756a\u53f7\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u306f?\" target=\"_blank\">Word VBA\u3067\u3001\u30ab\u30fc\u30bd\u30eb\u4f4d\u7f6e\u3068\u306f\u95a2\u4fc2\u306a\u304f\u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u306b\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u30da\u30fc\u30b8\u756a\u53f7\u3092\u53d6\u5f97\u3059\u308b\u306b\u306f\u3069\u3046\u3059\u308c\u3070\u826f\u3044\u304b\uff1f<\/a>\u300d\u3068\u3044\u3046\u8cea\u554f\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u305f\u3057\u304b\u306b\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u3092\u3088\u304f\u898b\u3066\u307f\u308b\u3068\u3001\u30b9\u30af\u30ed\u30fc\u30eb\u4f4d\u7f6e\u306b\u3088\u3063\u3066\u306f\u5fae\u5999\u306b\u4e0a\u8a18\u30de\u30af\u30ed\u3067\u53d6\u5f97\u3067\u304d\u308b\u756a\u53f7\u3068\u306f\u7570\u306a\u308b\u30da\u30fc\u30b8\u756a\u53f7\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e<i>\u201c\u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u306b\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u30da\u30fc\u30b8\u756a\u53f7\u201d<\/i>\u306e\u9700\u8981\u304c\u3069\u3053\u307e\u3067\u3042\u308b\u306e\u304b\u306f\u5206\u304b\u308a\u307e\u305b\u3093\u304c\u3001UIAutomation\u3092\u4f7f\u3063\u3066\u7121\u7406\u3084\u308a\u53d6\u5f97\u3059\u308b\u30b3\u30fc\u30c9\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">'UIAutomationClient(UIAutomationCore.dll)\u8981\u53c2\u7167\r\nOption Explicit\r\n\r\nPublic Sub Sample02()\r\n'\u30b9\u30c6\u30fc\u30bf\u30b9 \u30d0\u30fc\u304b\u3089\u30da\u30fc\u30b8\u756a\u53f7\u53d6\u5f97\r\n'\u203b\u300c\u30b9\u30c6\u30fc\u30bf\u30b9 \u30d0\u30fc\u300d\u3068\u300c\u30da\u30fc\u30b8\u756a\u53f7\u300d\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u524d\u63d0\r\n  Dim uiAuto As UIAutomationClient.CUIAutomation\r\n  Dim elm As UIAutomationClient.IUIAutomationElement\r\n  Dim ary As IUIAutomationElementArray\r\n  Dim acc As Office.IAccessible\r\n  Dim num As String\r\n  Dim v As Variant\r\n  Dim i As Long\r\n  \r\n  '\u30b9\u30c6\u30fc\u30bf\u30b9 \u30d0\u30fc\u304b\u3089IAccessible\u7d4c\u7531\u3067IUIAutomationElement\u53d6\u5f97\r\n  Set acc = Application.CommandBars(&quot;Status Bar&quot;)\r\n  Set uiAuto = New UIAutomationClient.CUIAutomation\r\n  Set elm = uiAuto.ElementFromIAccessible(acc, 0)\r\n  \r\n  '\u30b9\u30c6\u30fc\u30bf\u30b9 \u30d0\u30fc(NetUInetpane)\u53d6\u5f97\r\n  Set elm = GetElement(uiAuto, elm, UIA_ClassNamePropertyId, &quot;NetUInetpane&quot;)\r\n  '\u5b50\u8981\u7d20\u304b\u3089CurrentName\u306b&#x5B;\u30da\u30fc\u30b8\u756a\u53f7]\u304c\u542b\u307e\u308c\u308b\u3082\u306e\u3092\u53d6\u5f97\r\n  Set ary = elm.FindAll(TreeScope_Subtree, uiAuto.CreateTrueCondition)\r\n  For i = 0 To ary.Length - 1\r\n    num = ary.GetElement(i).CurrentName\r\n    If InStr(num, &quot;\u30da\u30fc\u30b8\u756a\u53f7&quot;) Then Exit For\r\n  Next\r\n  \r\n  '\u53d6\u5f97\u3057\u305f\u30da\u30fc\u30b8\u756a\u53f7\u6574\u5f62\r\n  num = Replace(num, &quot;\u30da\u30fc\u30b8\u756a\u53f7&quot;, &quot;&quot;)\r\n  num = Replace(num, &quot;\u30da\u30fc\u30b8&quot;, &quot;&quot;)\r\n  num = Trim(num)\r\n  v = Split(num, &quot;\/&quot;)\r\n  MsgBox &quot;\u30da\u30fc\u30b8\u756a\u53f7\uff1a&quot; &amp; v(LBound(v)) &amp; vbNewLine &amp; _\r\n         &quot;\u7dcf\u30da\u30fc\u30b8\u6570\uff1a&quot; &amp; v(UBound(v)), vbInformation + vbSystemModal\r\nEnd Sub\r\n\r\nPrivate Function GetElement(ByVal uiAuto As CUIAutomation, _\r\n                            ByVal elmParent As IUIAutomationElement, _\r\n                            ByVal propertyId As Long, _\r\n                            ByVal propertyValue As Variant, _\r\n                            Optional ByVal ctrlType As Long = 0) As IUIAutomationElement\r\n  Dim cndFirst As IUIAutomationCondition\r\n  Dim cndSecond As IUIAutomationCondition\r\n    \r\n  Set cndFirst = uiAuto.CreatePropertyCondition( _\r\n                   propertyId, _\r\n                   propertyValue _\r\n                 )\r\n  If ctrlType &lt;&gt; 0 Then\r\n    Set cndSecond = uiAuto.CreatePropertyCondition( _\r\n                      UIA_ControlTypePropertyId, _\r\n                      ctrlType _\r\n                    )\r\n    Set cndFirst = uiAuto.CreateAndCondition( _\r\n                     cndFirst, _\r\n                     cndSecond _\r\n                   )\r\n  End If\r\n  Set GetElement = elmParent.FindFirst(TreeScope_Subtree, cndFirst)\r\nEnd Function<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Word_VBA_PageNumber_02.jpg\" alt=\"\" width=\"858\" height=\"619\" class=\"alignnone size-full wp-image-8656\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Word_VBA_PageNumber_02.jpg 858w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Word_VBA_PageNumber_02-300x216.jpg 300w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Word_VBA_PageNumber_02-768x554.jpg 768w\" sizes=\"auto, (max-width: 858px) 100vw, 858px\" \/><\/p>\n<p>\u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u306b\u300c\u30da\u30fc\u30b8\u756a\u53f7\u300d\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u524d\u63d0\u3068\u306a\u308a\u307e\u3059\u304c\u3001\u3053\u308c\u3067\u4e00\u5fdc\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3082\u3057\u304b\u3057\u305f\u3089\u3001\u3082\u3063\u3068\u7c21\u5358\u306a\u65b9\u6cd5\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u4eca\u56de\u306f\u3053\u308c\u3067\u826f\u3057\u3068\u3057\u307e\u3059\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":"Word\u30de\u30af\u30ed\u3067\u9078\u629e\u4f4d\u7f6e\u306e\u30da\u30fc\u30b8\u756a\u53f7\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u3001\u7c21\u5358\u306a\u306e\u306fSelection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306eInformation\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u3046\u65b9\u6cd5\u3067\u3059\u3002 Public Sub Sample01() With Selection M [&hellip;]","protected":false},"author":1,"featured_media":7136,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"[\u30da\u30fc\u30b8\u756a\u53f7\u3092\u53d6\u5f97\u3059\u308bWord\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,49],"tags":[],"class_list":["post-8654","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-word-office"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-WordVBA.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-2fA","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/8654","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=8654"}],"version-history":[{"count":1,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/8654\/revisions"}],"predecessor-version":[{"id":8657,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/8654\/revisions\/8657"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7136"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}