Consulting

Results 1 to 3 of 3

Thread: Macro to change the font of page number to New Rocker in Word 2007

  1. #1

    Macro to change the font of page number to New Rocker in Word 2007

    Hi guys.

    I have 200 word documents and I want to change the font of the page number (in the footer) to New Rocker font so that it matches the text on the page.

    Can I do that using a macro ?

    Thanks!

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    For that you could use a macro like:
    Sub UpdateDocuments()
    Application.ScreenUpdating = False
    Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document
    Dim Sctn As Section, HdFt As HeaderFooter
    strDocNm = ActiveDocument.FullName
    strFolder = GetFolder
    If strFolder = "" Then Exit Sub
    strFile = Dir(strFolder & "\*.doc", vbNormal)
    While strFile <> ""
      If strFolder & "\" & strFile <> strDocNm Then
        Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
        With wdDoc
          For Each Sctn In .Sections
            If Sctn.Index = 1 Then
              For Each HdFt In Sctn.Footers
                If HdFt.Exists = True Then Call FooterUpdate(HdFt)
              Next
            Else
              For Each HdFt In Sctn.Footers
                If HdFt.Exists = True Then
                  If HdFt.LinkToPrevious = False Then Call FooterUpdate(HdFt)
                End If
              Next
            End If
          Next
          .Close SaveChanges:=True
        End With
      End If
      strFile = Dir()
    Wend
    Set wdDoc = Nothing
    Application.ScreenUpdating = True
    End Sub
    
    
    Sub FooterUpdate(HdFt As HeaderFooter)
    Dim Fld As Field
    For Each Fld In HdFt.Range.Fields
      With Fld
        If .Type = wdFieldPage Then
          With .Code
            If InStr(UCase(.Text), "CHARFORMAT") = 0 Then
              .Text = .Text & "\* Charformat"
            End If
            .Font.Name = "New Rocker"
          End With
          Exit For
        End If
      End With
    Next
    End Sub
    
    
    Function GetFolder() As String
    Dim oFolder As Object
    GetFolder = ""
    Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
    If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
    Set oFolder = Nothing
    End Function
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Thats just great man

    Thank you so much.

    Have a Happy New Year!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •