View Single Post
 
Old 09-21-2016, 02:04 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,512
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try something based on:
Code:
Sub EditHeaderTextBox()
Dim Shp As Shape, Doc As Document, strText As String
Dim i As Long, docToOpen As FileDialog, sHght As Single
    
    On Error GoTo Err_Exit
    strText = InputBox("New Text", "Header Textbox Update", "New Text")
    
    ' Switch off the updates of screen
    Application.ScreenUpdating = False
    
    Set docToOpen = Application.FileDialog(msoFileDialogFilePicker)
    docToOpen.Show
    For i = 1 To docToOpen.SelectedItems.Count
        'Open each document
        Set Doc = Documents.Open(FileName:=docToOpen.SelectedItems(i))
        With Doc
            With .Sections(1)
                For Each Shp In .Headers(wdHeaderFooterPrimary).Shapes
                    With Shp
                        If .Type = msoTextBox And .Name = "Text Box 1" Then
                            With .TextFrame
                                .AutoSize = True
                                .MarginLeft = 0
                                With .TextRange
                                    With .Font
                                        .Name = "Arial"
                                        .Size = 10
                                    End With
                                    .Text = strText
                                End With
                            End With
                        End If
                        .RelativeVerticalPosition = wdRelativeVerticalPositionPage
                        sHght = .Top + .Height
                    End With
                Next
                .PageSetup.TopMargin = sHght
            End With
            .Close SaveChanges:=wdSaveChanges
        End With
    Next
    
    Set docToOpen = Nothing: Set Doc = Nothing
    ' Switch SCreen updates back on
    Application.ScreenUpdating = True
    Exit Sub
Err_Exit:
    MsgBox Err.Description & Err.Number
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote