Microsoft 製品に組み込まれている Visual Basic の実装。
こんにちは。
> 1. ページ番号が表示されているか
2003で確認したところ、ページ番号が表示されているかどうかを直接取得するプロパティやメソッドが無さそうでしたので、下記のようにPageNumbersコレクションのCountプロパティで判断してみてはいかがでしょうか?
Option Explicit
Public Sub Sample()
If ChkPageNumber Then
MsgBox "ヘッダー・フッター上にページ番号があります。"
Else
MsgBox "ヘッダー・フッター上にページ番号がありません。"
End If
End Sub
Public Function ChkPageNumber() As Boolean
Dim sec As Word.Section
Dim hed As Word.HeaderFooter
Dim fot As Word.HeaderFooter
Dim ret As Boolean
ret = False '初期化
For Each sec In ActiveDocument.Sections
For Each hed In sec.Headers
If hed.Exists Then
If hed.PageNumbers.Count > 0 Then
ret = True
GoTo BottomRow
End If
End If
Next
For Each fot In sec.Footers
If fot.Exists Then
If fot.PageNumbers.Count > 0 Then
ret = True
GoTo BottomRow
End If
End If
Next
Next
BottomRow:
ChkPageNumber = ret
End Function
> 2. フィールドコードの内容
内容がどういったものを指すのかが分からないのですが、FieldオブジェクトのResultプロパティなりCodeプロパティなりで取得することができるかと思います。
Public Sub Sample2()
If ActiveDocument.Fields.Count > 0 Then
Debug.Print ActiveDocument.Fields(1).Result 'フィールドの結果
Debug.Print ActiveDocument.Fields(1).Code 'フィールドコード
End If
End Sub