{"id":6505,"date":"2016-01-03T21:26:45","date_gmt":"2016-01-03T12:26:45","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=6505"},"modified":"2016-01-03T21:26:45","modified_gmt":"2016-01-03T12:26:45","slug":"%e5%90%84%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e7%94%bb%e5%83%8f%e3%81%ab%e5%a4%89%e6%8f%9b%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=6505","title":{"rendered":"\u5404\u30da\u30fc\u30b8\u3092\u753b\u50cf\u306b\u5909\u63db\u3059\u308bWord\u30de\u30af\u30ed"},"content":{"rendered":"<p>Excel MVP\u306e<a href=\"https:\/\/twitter.com\/kiyotoi\" title=\"Kiyoto ITO(@kiyotoi)\u3055\u3093\" target=\"_blank\">\u4f0a\u85e4\u3055\u3093<\/a>\u304c\u30d6\u30ed\u30b0\u3067\u3001<a href=\"http:\/\/www.relief.jp\/itnote\/archives\/word-vba-select-page.php\" title=\"VBA\u3067Word\u6587\u66f8\u306e\u30da\u30fc\u30b8\u5168\u4f53\u3092\u53d6\u5f97\u30fb\u9078\u629e\u3059\u308b\" target=\"_blank\">Word\u306ePage\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6271\u3046\u30de\u30af\u30ed<\/a>\u3092\u7d39\u4ecb\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3042\u307e\u308a\u6271\u308f\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u3053\u306ePage\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u306f\u30da\u30fc\u30b8\u5185\u5bb9\u3092\u753b\u50cf\u5f62\u5f0f\u3067\u53d6\u5f97\u3067\u304d\u308b<a href=\"https:\/\/msdn.microsoft.com\/ja-jp\/library\/ff821585.aspx\" title=\"Page.EnhMetaFileBits \u30d7\u30ed\u30d1\u30c6\u30a3 (Word)(\u6a5f\u68b0\u7ffb\u8a33)\" target=\"_blank\">EnhMetaFileBits\u30d7\u30ed\u30d1\u30c6\u30a3<\/a>\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u540d\u524d\u306e\u901a\u308a\u3001\u3053\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u304b\u3089\u306f<a href=\"https:\/\/ja.wikipedia.org\/wiki\/Windows_Metafile\" title=\"Windows Metafile - Wikipedia\" target=\"_blank\">EMF\u5f62\u5f0f<\/a>\u306e\u30d0\u30a4\u30c8\u914d\u5217\u304c\u8fd4\u3063\u3066\u304f\u308b\u306e\u3067\u3001\u3053\u308c\u3092\u4f7f\u3046\u3068\u5404\u30da\u30fc\u30b8\u3092\u753b\u50cf\u3068\u3057\u3066\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Option Explicit\r\n\r\nPublic Sub Sample()\r\n  DocumentToEMF &quot;C:\\Test\\EMF&quot;\r\nEnd Sub\r\n\r\nPublic Sub DocumentToEMF(ByVal SaveFolderPath As String)\r\n  Dim tmp As Word.WdViewType\r\n  Dim p As Word.Page\r\n  Dim i As Long\r\n  Const adTypeBinary = 1\r\n  Const adSaveCreateOverWrite = 2\r\n \r\n  i = 1 '\u521d\u671f\u5316\r\n  SaveFolderPath = AddPathSeparator(SaveFolderPath)\r\n  tmp = ActiveWindow.View.Type\r\n  ActiveWindow.View.Type = wdPrintPreview\r\n  With CreateObject(&quot;ADODB.Stream&quot;)\r\n    .Type = adTypeBinary\r\n    For Each p In ActiveWindow.ActivePane.Pages\r\n      .Open\r\n      .Position = 0\r\n      .Write p.EnhMetaFileBits\r\n      .SaveToFile SaveFolderPath &amp; &quot;Page&quot; &amp; i &amp; &quot;.emf&quot;, adSaveCreateOverWrite\r\n      .Close\r\n      i = i + 1\r\n    Next\r\n  End With\r\n  ActiveWindow.View.Type = tmp\r\nEnd Sub\r\n\r\nPrivate Function AddPathSeparator(ByVal str As String) As String\r\n'\u30d1\u30b9\u306e\u533a\u5207\u308a\u6587\u5b57\u8ffd\u52a0\r\n  If Right(str, 1) &lt;&gt; ChrW(92) Then str = str &amp; ChrW(92)\r\n  AddPathSeparator = str\r\nEnd Function<\/pre>\n<p>EnhMetaFileBits\u30d7\u30ed\u30d1\u30c6\u30a3\u306fPage\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u4ee5\u5916\u306b\u3082\u3001Selection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3084Range\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u3082\u3042\u308b\u306e\u3067\u3001\u7279\u5b9a\u306e\u7bc4\u56f2\u306e\u307f\u3092\u753b\u50cf\u5316\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u305d\u3061\u3089\u3092\u4f7f\u3046\u3068\u826f\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Excel MVP\u306e\u4f0a\u85e4\u3055\u3093\u304c\u30d6\u30ed\u30b0\u3067\u3001Word\u306ePage\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6271\u3046\u30de\u30af\u30ed\u3092\u7d39\u4ecb\u3055\u308c\u3066\u3044\u307e\u3059\u3002 \u3042\u307e\u308a\u6271\u308f\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u3053\u306ePage\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u306f\u30da\u30fc\u30b8\u5185\u5bb9\u3092\u753b\u50cf\u5f62\u5f0f\u3067\u53d6\u5f97\u3067\u304d\u308bEnhMetaFile [&hellip;]","protected":false},"author":1,"featured_media":7134,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"[\u5404\u30da\u30fc\u30b8\u3092\u753b\u50cf\u306b\u5909\u63db\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-6505","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-Word.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-1GV","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6505","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=6505"}],"version-history":[{"count":1,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6505\/revisions"}],"predecessor-version":[{"id":6506,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6505\/revisions\/6506"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7134"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}