Word VBA質問箱 IV

当質問箱は、有志のボランティア精神のおかげで成り立っています。
問題が解決したら、必ずお礼をしましょうね。
本サイトの基本方針をまとめました。こちら をご一読ください。

投稿種別の選択が必要です。ご注意ください。
迷惑投稿防止のため、URLの入力を制限しています。ご了承ください。


37 / 306 ツリー ←次へ | 前へ→

【243】縦横の識別方法、セクションの連続の識別方法 じゅげむ 05/2/2(水) 9:47 質問[未読]
【773】Re:縦横の識別方法、セクションの連続の識別... マナ 13/5/26(日) 16:51 発言[未読]

【243】縦横の識別方法、セクションの連続の識別方...
質問  じゅげむ  - 05/2/2(水) 9:47 -

引用なし
パスワード
   用紙の縦には、縦用ヘッダー、用紙の横には、横用のヘッダーを
それぞれ付加したいのですが、識別する方法はありますか?
又、ヘッダーが連続かどうかを識別する方法はありますか?

コマンドを次のようにして動かして見ましたが上手く動作しませんでした。
  With Selection.PageSetup
   If .PageWidth = MillimetersToPoints(210) Then
    If .PageHeight = MillimetersToPoints(297) Then
     If .SectionStart = wdSectionContinuous Then
     Else
      NormalTemplate.AutoTextEntries("QC054_copy_mark").Insert Where:=Selection.Range
     End If
    End If
   Else
    If .PageHeight = MillimetersToPoints(297) Then
    Else
     If .SectionStart = wdSectionContinuous Then
     Else
      NormalTemplate.AutoTextEntries("QC054_copy_mark_yoko").Insert Where:=Selection.Range
     End If
    End If
   End If
    
  End With

【773】Re:縦横の識別方法、セクションの連続の識...
発言  マナ  - 13/5/26(日) 16:51 -

引用なし
パスワード
   今更ですが、やりたかったであろうことは、こんな感じでしょうか。

Sub test()
  Dim s As Section
  
  For Each s In ActiveDocument.Sections
    With s.Headers(wdHeaderFooterPrimary)
      .LinkToPrevious = False
      If s.PageSetup.Orientation = wdOrientLandscape Then
        NormalTemplate.AutoTextEntries("横用H").Insert where:=.Range
      Else
        NormalTemplate.AutoTextEntries("縦用H").Insert where:=.Range
      End If
    End With
  Next

End Sub

37 / 306 ツリー ←次へ | 前へ→
ページ:  ┃  記事番号:
206491
(SS)C-BOARD v3.8 is Free