none
replace fonts with multiple formating RRS feed

  • Question

  • I need a macro to find & replace fonts with multiple formating.

    I have tried the find & replace change font option but it is not working.

    REASON : The document is having multiple fonts with different character spacing condition  like scale & spacing & position in most of the pages

    I need a macro to neutralize all the character spacing condition  in all the pages.

    if possible all the fonts be converted to Arial regardless whatever fonts are present in the document.


    ALI


    • Edited by ALI74 Tuesday, January 8, 2013 2:58 PM
    Tuesday, January 8, 2013 2:56 PM

Answers

  • The following macro will process all documents in a folder and set scaling to 100, spacing to 0 and position to 0.

    Sub FormatDocs()
        Dim strFolder As String
        Dim strFile As String
        Dim doc As Document
        With Application.FileDialog(4) ' msoFileDialogFolderPicker
            If .Show Then
                strFolder = .SelectedItems(1)
            Else
                MsgBox "No folder selected.", vbExclamation
                Exit Sub
            End If
        End With
        Application.ScreenUpdating = False
        If Right(strFolder, 1) <> "\" Then
            strFolder = strFolder & "\"
        End If
        strFile = Dir(strFolder & "*.doc*")
        Do While strFile <> ""
            Set doc = Documents.Open(strFolder & strFile)
            With doc.Content.Font
                .Scaling = 100
                .Spacing = 0
                .Position = 0
            End With
            doc.Close SaveChanges:=True
            strFile = Dir
        Loop
        Application.ScreenUpdating = True
    End Sub


    Regards, Hans Vogelaar

    • Marked as answer by ALI74 Tuesday, January 8, 2013 4:42 PM
    Tuesday, January 8, 2013 3:41 PM

All replies

  • If you want to remove all character spacing, can't you simply select the entire document (Ctrl+A) and press Ctrl+Spacebar to reset the character formatting? Or if you want to keep other character formatting options such as bold or italic, select the entire document, activate the Format Font dialog (Ctrl+D), activate the Advanced tab, set Scale to 100%, Spacing to Normal, and Position to Normal, then click OK.

    Regards, Hans Vogelaar

    Tuesday, January 8, 2013 3:06 PM
  • Thank you for replying...

    but i need to run the macro in mutiple documents placed in a folder... the folder contains atleast 300 document. all the document are having difffernt fonts with differnt character spacing which I cant replace using the find & replace 

    it would be a herculan task to modify all the documents manually ... hence the request.....

    some fonts are with scale 100% & expanded by 0.5 pt while in some the scale is 50% & character spacing expanded by 1 pt etc........

    If the characters spacing are neutralized then I can use the find & replace fuction to change the fonts througha macro


    ALI

    Tuesday, January 8, 2013 3:13 PM
  • The following macro will process all documents in a folder and set scaling to 100, spacing to 0 and position to 0.

    Sub FormatDocs()
        Dim strFolder As String
        Dim strFile As String
        Dim doc As Document
        With Application.FileDialog(4) ' msoFileDialogFolderPicker
            If .Show Then
                strFolder = .SelectedItems(1)
            Else
                MsgBox "No folder selected.", vbExclamation
                Exit Sub
            End If
        End With
        Application.ScreenUpdating = False
        If Right(strFolder, 1) <> "\" Then
            strFolder = strFolder & "\"
        End If
        strFile = Dir(strFolder & "*.doc*")
        Do While strFile <> ""
            Set doc = Documents.Open(strFolder & strFile)
            With doc.Content.Font
                .Scaling = 100
                .Spacing = 0
                .Position = 0
            End With
            doc.Close SaveChanges:=True
            strFile = Dir
        Loop
        Application.ScreenUpdating = True
    End Sub


    Regards, Hans Vogelaar

    • Marked as answer by ALI74 Tuesday, January 8, 2013 4:42 PM
    Tuesday, January 8, 2013 3:41 PM