none
problem with add shapebox to footer RRS feed

  • Question

  • I want add footer to all pages in document.

    But In second page, it put my shapebox in header and not in footer.

    what is it happen?

    I write this:

    Sub SetFotterText()
       Dim shpTbWarning As Shape
       Dim rng As Range
       Dim top As Single
       Dim lft As Single
    On Error Resume Next
            Set rng = Word.ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Range
            top = rng.Information(wdVerticalPositionRelativeToPage)
            lft = rng.Information(wdHorizontalPositionRelativeToPage)
             
            addTBWarning shpTbWarning, "textBoxWarningF", rng, top, lft
             
            
             
            ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
            If (ActiveDocument.BuiltInDocumentProperties(wdPropertyPages) = 1) Then
                        Selection.InsertBreak Type:=wdPageBreak
        
                        flagPage = True
           End If
                
            Set rng = Word.ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
            top = rng.Information(wdVerticalPositionRelativeToPage)
            lft = rng.Information(wdHorizontalPositionRelativeToPage)
            
            addTBWarning shpTbWarning, "textBoxWarningA", rng, top, lft
            
            checkFlagPage
            
            'Switch back to Normal View
             ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
     
       
       
           
            ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
            Selection.GoTo what:=wdGoToPage, Which:=1
             Selection.HomeKey Unit:=wdStory
            Selection.MoveDown Unit:=wdLine, count:=2
            
              
          
    End Sub
    Sub addTBWarning(shpTbWarning As Shape, tbName As String, rng As Range, top As Single, lft As Single)
    On Error Resume Next
        Set shpTbWarning = ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, lft, top, 350, 38, rng)
        
        
        
        
        
      
        
        shpTbWarning.Left = wdShapeCenter
        With shpTbWarning
            .Name = tbName
            .Line.ForeColor = vbBlue
             With .TextFrame
                .TextRange.ParagraphFormat.Alignment = wdAlignParagraphCenter
                 .TextRange.ParagraphFormat.ReadingOrder = wdReadingOrderRtl
            End With
            With .TextFrame.TextRange.Font
                 .Name = "Narkisim"
                 .Size = 9
                 .NameBi = "Narkisim"
                 .SizeBi = 9
                 .Color = wdColorBlue
            End With
             With .TextFrame.TextRange.ParagraphFormat
                  .LineSpacing = LinesToPoints(1)
            End With
            
        End With
                                                                  
        'Set reference to TextBox Range
       Set rng = shpTbWarning.TextFrame.TextRange
          
        'Insert Text and Fields
        With rng
             .InsertParagraphAfter
             .InsertAfter "My Text in ""Footer"
             .InsertParagraphAfter
             .MoveEnd Unit:=wdCharacter, count:=rng.Characters.count + 3
         End With
        
       
    End Sub

    Sunday, June 10, 2012 12:04 PM

Answers

  • Hi,

    I cann't reproduce your issue becase the "checkFlagPage" is not defined in Word 2010.Would you  clarify what it is ? However, I run the code after omiting the "chechFlagPage" ,then I get the senario as  the following figure

    The code works fine.Do you try it again?

    Hope this helps.

    Thanks,

    Leo

    Monday, June 11, 2012 6:58 AM