Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change font size and type (2003)

    Hi all,

    I am trying to write a script that will change the font and size of font to Arial 11 of 750'000 files. The only way I can think of is to use a script where I can select the directory where the .doc files are and then the script will open each file in turn, select all and change the font and size.

    Only problem I have is the command to change the font and size.

    And the other possible problem is I think I will need to change the default font and size as well to prevent furture additions to the .doc files typing to the old font or size

    Many thanks
    Kevin
    Regards
    Gerbil (AKA Kevin)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change font size and type (2003)

    Should ALL text in the documents change to Arial 11? There are no titles, headings etc. that require a larger font, etc.?

  3. #3
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change font size and type (2003)

    As far as Im awear everything must, change but whilst your meantioning it, I suppose there is way that to specify what changes using an iF statement. IF Heading = "Heading1" Then .....

    Thanks
    Regards
    Gerbil (AKA Kevin)

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change font size and type (2003)

    Yes, but it'll become very slow and complicated.
    Perhaps it would be better to leave the documents as they are, and just modify the ones that are opened.

  5. #5
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change font size and type (2003)

    OK well thats say I want to change the whole document to arial and size 11.

    How would I do that.

    How would I modify just the ones that are opened. Do you mean as the user opens them it will change the font and sie before they start typing etc.

    Thanks Hans
    Regards
    Gerbil (AKA Kevin)

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change font size and type (2003)

    You could create a macro named AutoOpen in the user's Normal.dot. It would run whenever a document is opened, so it will affect ALL documents, and you'd lose ALL formatting, so I don't think that's an attractive idea. Better let the user run a macro when necessary. Here's an example, based on Replace Text Anywhere in a Document.

    Sub MakeDefault()
    Dim rngStory As Word.Range
    Dim lngJunk As Long
    Dim oShp As Shape

    Application.ScreenUpdating = False
    ' Set Normal style
    With ActiveDocument.Styles(wdStyleNormal).Font
    .Name = "Arial"
    .Size = 11
    End With
    'Fix the skipped blank Header/Footer problem
    lngJunk = ActiveDocument.Sections(1).Headers(1).Range.StoryT ype
    'Iterate through all story types in the current document
    For Each rngStory In ActiveDocument.StoryRanges
    'Iterate through all linked stories
    Do
    SetFont rngStory
    On Error Resume Next
    Select Case rngStory.StoryType
    Case 6, 7, 8, 9, 10, 11
    If rngStory.ShapeRange.Count > 0 Then
    For Each oShp In rngStory.ShapeRange
    If oShp.TextFrame.HasText Then
    SetFont oShp.TextFrame.TextRange
    End If
    Next
    End If
    End Select
    On Error GoTo 0
    'Get next linked story (if any)
    Set rngStory = rngStory.NextStoryRange
    Loop Until rngStory Is Nothing
    Next
    Application.ScreenUpdating = True
    End Sub

    Sub SetFont(ByVal rngStory As Word.Range)
    rngStory.Style = ActiveDocument.Styles(wdStyleNormal)
    rngStory.ParagraphFormat.Reset
    rngStory.Font.Reset
    End Sub

    Note: the code will fail on protected documents.

Posting Permissions

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