{"id":657,"date":"2018-07-03T09:08:11","date_gmt":"2018-07-03T00:08:11","guid":{"rendered":"https:\/\/elleneast.com\/?p=657"},"modified":"2018-08-06T21:15:23","modified_gmt":"2018-08-06T12:15:23","slug":"%e3%80%90word-vba%e3%80%91%e6%9b%b8%e5%bc%8f%e3%82%92%e6%a4%9c%e7%b4%a2%e3%81%99%e3%82%8b%e3%81%a8%e6%b0%b8%e4%b9%85%e3%83%ab%e3%83%bc%e3%83%97%e3%81%97%e3%81%a6%e3%81%97%e3%81%be%e3%81%86%e5%a0%b4","status":"publish","type":"post","link":"https:\/\/elleneast.com\/?p=657","title":{"rendered":"\u3010Word VBA\u3011\u66f8\u5f0f\u3092\u691c\u7d22\u3059\u308b\u3068\u6c38\u4e45\u30eb\u30fc\u30d7\u3057\u3066\u3057\u307e\u3046\u5834\u5408"},"content":{"rendered":"<p>Word VBA \u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3067\u3001\u66f8\u5f0f\u3092\u691c\u7d22\u3057\u3066\u30eb\u30fc\u30d7\u51e6\u7406\u3057\u3066\u3044\u304f\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u5b9f\u884c\u3059\u308b\u3068\u3001\u306a\u305c\u304b\u539f\u56e0\u4e0d\u660e\u306e\u6c38\u4e45\u30eb\u30fc\u30d7\u306b\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u3068\u3044\u3046\u7d4c\u9a13\u306f\u7121\u3044\u3067\u3057\u3087\u3046\u304b\uff1f<br \/>\n\u305f\u3068\u3048\u3070\u6b21\u306e\u30b3\u30fc\u30c9\u306f\u3001Word \u6587\u66f8\u4e0a\u306e\u592a\u5b57\u306e\u6587\u5b57\u3092\u8d64\u5b57\u306b\u3057\u3066\u3001\u51e6\u7406\u304c\u7d42\u308f\u3063\u305f\u3089\u300c\u7d42\u4e86\u300d\u3068\u8868\u793a\u3059\u308b\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<pre class=\"lang:vbnet decode:true\">Sub a1()\n\nDim oRange As Range\nSet oRange = ActiveDocument.Range\nDim oFind As Find\nSet oFind = oRange.Find\noFind.ClearFormatting\noFind.Format = True\noFind.Font.Bold = True '\u592a\u5b57\u3092\u691c\u7d22\noFind.Forward = True\nDo While oFind.Execute = True\n    oRange.Font.ColorIndex = wdRed\n    Call oRange.SetRange(oRange.End, oRange.End)\nLoop\nMsgBox \"\u7d42\u4e86\"\n\nEnd Sub<\/pre>\n<p>\u307b\u3068\u3093\u3069\u306e\u5834\u5408\u3001\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u306f\u6b63\u5e38\u306b\u52d5\u4f5c\u3057\u307e\u3059\u304c\u3001\u7a00\u306b\u6c38\u4e45\u30eb\u30fc\u30d7\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u51e6\u7406\u304c\u7d42\u308f\u3089\u306a\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u592a\u5b57\u306e\u6587\u5b57\u304c\u3082\u3046\u6587\u66f8\u4e0a\u306b\u306f\u898b\u3064\u304b\u3089\u306a\u3044\u306b\u3082\u95a2\u308f\u3089\u305a\u3001oFind.Execute \u304c True \u3092\u8fd4\u3057\u7d9a\u3051\u308b\u304b\u3089\u3067\u3059\u3002<br \/>\n\u3053\u308c\u306f\u6587\u66f8\u306b\u30d0\u30b0\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u5834\u5408\u306b\u8d77\u304d\u308b\u73fe\u8c61\u3068\u8003\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>\u79c1\u306f\u8272\u3005\u3068\u8a66\u3057\u305f\u7d50\u679c\u3001\u30b3\u30fc\u30c9\u3092\u4e0b\u8a18\u306e\u3088\u3046\u306b\u4fee\u6b63\u3059\u308b\u3053\u3068\u3067\u3053\u306e\u554f\u984c\u3092\u56de\u907f\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:vbnet mark:8-9,14-17,22-23 decode:true\">Sub a2()\n\nDim oRange As Range\nSet oRange = ActiveDocument.Range\nDim oFind As Find\nSet oFind = oRange.Find\noFind.ClearFormatting\noFind.MatchWildcards = True '\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u691c\u7d22\noFind.Text = \"?\" '1\u6587\u5b57\u691c\u7d22\noFind.Format = True\noFind.Font.Bold = True '\u592a\u5b57\u3092\u691c\u7d22\noFind.Forward = True\nDo While oFind.Execute = True\n    Call oRange.SetRange(oRange.Start, oRange.Start) '\u592a\u5b571\u6587\u5b57\u304c\u898b\u3064\u304b\u3063\u305f\u3089\u305d\u306e\u76f4\u524d\u306b\u691c\u7d22\u4f4d\u7f6e\u3092\u623b\u3059\n    oFind.MatchWildcards = False '\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u691c\u7d22\u3092\u30aa\u30d5\n    oFind.Text = \"\" '\u30c6\u30ad\u30b9\u30c8\u6307\u5b9a\u3092\u3057\u306a\u3044\n    oFind.Execute '\u592a\u5b57\u3092\u518d\u691c\u7d22\u3002\u9023\u7d9a\u3059\u308b1\u6587\u5b57\u4ee5\u4e0a\u306e\u592a\u5b57\u306b\u30d2\u30c3\u30c8\u3059\u308b\n\n    oRange.Font.ColorIndex = wdRed\n    Call oRange.SetRange(oRange.End, oRange.End)\n\n    oFind.MatchWildcards = True '\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u691c\u7d22\u306b\u623b\u3059\n    oFind.Text = \"?\" '1\u6587\u5b57\u691c\u7d22\nLoop\nMsgBox \"\u7d42\u4e86\"\n\nEnd Sub<\/pre>\n<p>\u524d\u8ff0\u306e\u4e0d\u5177\u5408\u304c\u8d77\u304d\u308b\u5834\u5408\u3001\u30c6\u30ad\u30b9\u30c8\u3092\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u3067\u6307\u5b9a\u3057\u305f\u4e0a\u3067\u66f8\u5f0f\u691c\u7d22\u3059\u308b\u3068\u305d\u306e\u4e0d\u5177\u5408\u3092\u306a\u305c\u304b\u56de\u907f\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\uff0b\u66f8\u5f0f\u6307\u5b9a\u3067\u691c\u7d22\u304c\u30d2\u30c3\u30c8\u3057\u305f\u3089\u3001\u691c\u7d22\u4f4d\u7f6e\u3092\u623b\u3057\u3066\u518d\u3073\uff08\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u3092\u4f7f\u308f\u306a\u3044\uff09\u901a\u5e38\u306e\u66f8\u5f0f\u691c\u7d22\u3092\u3059\u308b\u3068\u3001\u6b63\u5e38\u306b\u51e6\u7406\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u524d\u8ff0\u306e 2 \u3064\u306e\u30b3\u30fc\u30c9\u306f\u3001Range.Find \u3092\u4f7f\u7528\u3057\u305f\u3084\u308a\u65b9\u3067\u3059\u304c\u3001Selection.Find \u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vbnet mark:8-10,15-18,23-24 decode:true \">Sub a3()\n\nDim oRange As Range\nSet oRange = ActiveDocument.Range\nDim oFind As Find\nSet oFind = Selection.Find\noFind.ClearFormatting\noFind.MatchFuzzy = False 'Selection.Find \u306e\u5834\u5408\u306f\u3053\u308c\u3092\u3057\u3066\u304a\u304b\u306a\u3044\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b\noFind.MatchWildcards = True '\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u691c\u7d22\noFind.Text = \"?\" '1\u6587\u5b57\u691c\u7d22\noFind.Format = True\noFind.Font.Bold = True '\u592a\u5b57\u3092\u691c\u7d22\noFind.Forward = True\nDo While oFind.Execute = True\n    Selection.MoveLeft '\u592a\u5b571\u6587\u5b57\u304c\u898b\u3064\u304b\u3063\u305f\u3089\u305d\u306e\u76f4\u524d\u306b\u691c\u7d22\u4f4d\u7f6e\u3092\u623b\u3059\n    oFind.MatchWildcards = False '\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u691c\u7d22\u3092\u30aa\u30d5\n    oFind.Text = \"\" '\u30c6\u30ad\u30b9\u30c8\u6307\u5b9a\u3092\u3057\u306a\u3044\n    oFind.Execute '\u592a\u5b57\u3092\u518d\u691c\u7d22\u3002\u9023\u7d9a\u3059\u308b1\u6587\u5b57\u4ee5\u4e0a\u306e\u592a\u5b57\u306b\u30d2\u30c3\u30c8\u3059\u308b\n\n    Selection.Font.ColorIndex = wdRed\n    Selection.MoveRight\n\n    oFind.MatchWildcards = True '\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u691c\u7d22\u306b\u623b\u3059\n    oFind.Text = \"?\" '1\u6587\u5b57\u691c\u7d22\nLoop\nMsgBox \"\u7d42\u4e86\"\n\nEnd Sub\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Word VBA \u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3067\u3001\u66f8\u5f0f\u3092\u691c\u7d22\u3057\u3066\u30eb\u30fc\u30d7\u51e6\u7406\u3057\u3066\u3044\u304f\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u5b9f\u884c\u3059\u308b\u3068\u3001\u306a\u305c\u304b\u539f\u56e0\u4e0d\u660e\u306e\u6c38\u4e45\u30eb\u30fc\u30d7\u306b\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u3068\u3044\u3046\u7d4c\u9a13\u306f\u7121\u3044\u3067\u3057\u3087\u3046\u304b\uff1f \u305f\u3068\u3048\u3070\u6b21\u306e\u30b3\u30fc\u30c9\u306f\u3001Word \u6587\u66f8\u4e0a\u306e\u592a\u5b57\u306e\u6587\u5b57\u3092 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":2420,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[57],"tags":[46,58],"class_list":{"0":"post-657","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-57","8":"tag-vba","9":"tag-word-vba"},"_links":{"self":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=657"}],"version-history":[{"count":3,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/657\/revisions"}],"predecessor-version":[{"id":863,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/657\/revisions\/863"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/media\/2420"}],"wp:attachment":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}