Article ID: 183648
Article Last Modified on 6/17/2005
Sub ForEntireDocument()
Dim oDoc As Document
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
MsgBox oStory.Text
Next
End Sub
Sub GetTextBoxTextInHeader()
Dim sSection As Section
Dim hHeader As HeaderFooter
Dim shpShape As Shape
' Loop through each section in the document.
For Each sSection In ActiveDocument.Sections
' Loop through each header in each section.
For Each hHeader In sSection.Headers
' If the header is the Primary header.
If hHeader.Index = wdHeaderFooterPrimary Then
' Loop through each Shape object in the header.
For Each shpShape In hHeader.Shapes
' If the shapetype is a text box.
If shpShape.Type = msoTextBox Then
' Display the text in each textbox found.
MsgBox shpShape.TextFrame.TextRange.Text
End If
Next
End If
Next
Next
End Sub
181058 OFF98: How to Run Sample Code from Knowledge Base Articles
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: wordcon vb vba vbe
Keywords: kbbug kbmacroexample kbpending KB183648