View Single Post
 
Old 08-29-2011, 01:40 PM
DugganSC DugganSC is offline Windows XP Office 2007
Novice
 
Join Date: Aug 2011
Posts: 8
DugganSC is on a distinguished road
Thumbs up

Ah, figured it out. The object was embedded as a Shape. I discovered this by first realizing that there was a Context Menu item to open the embedded document whereupon I recorded a macro to access it. For the sake of reference, the macro code I got for finding it, opening it, finding a piece of text, copying what followed it, closing the document, and pasting said text into the header is the following:
Code:
If ActiveDocument.Shapes.Count > 0 Then
        ActiveDocument.Shapes(1).Select
        Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
        
        With Selection.ParagraphFormat
            .LeftIndent = InchesToPoints(0#)
            .FirstLineIndent = InchesToPoints(0#)
        End With
        
        Selection.ShapeRange(1).OLEFormat.DoVerb VerbIndex:=1
    
        Selection.Find.ClearFormatting
        With Selection.Find
            .Text = "Document ID"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute
        Selection.MoveDown Unit:=wdLine, Count:=1
        Selection.HomeKey Unit:=wdLine
        Selection.EndKey Unit:=wdLine, Extend:=wdExtend
        Selection.Copy
        Selection.EscapeKey
        ActiveDocument.Close
        WordBasic.ViewFooterOnly
        Selection.TypeText Text:="Document "
        ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    Else
        MsgBox ("Failed to find cover page")
    End If

Last edited by DugganSC; 08-29-2011 at 01:42 PM. Reason: Fixing a zero-index issue
Reply With Quote