This code worked when used in MS Word, now trying to run from excel. I want to format all the text in the document with the same font type and the same font size.
'Format document with universal font type and size
    Selection.WholeStory
    Selection.Font.Name = "Calibri"
    Selection.Font.Size = 11
    End With
This one also did not work:
ActiveDocument.Range.Font.Color = wdColorAutomatic
ActiveDocument.Range.Font.Name = "Calibri"
ActiveDocument.Range.Font.Size = 11
I guess this is in continuation to your last question. Try this. I have not deleted certain declarations from the previous code.
Const wdFindContinue = 1
Sub FnFindAndFormat()
    Dim FileToOpen
    Dim objWord As Object, objDoc As Object, Rng As Object
    Dim MyAr() As String, strToFind As String
    Dim i As Long
    '~~> This holds your search words
    strToFind = "deal,contract,sign,award"
    '~~> Create an array of text to be found
    MyAr = Split(strToFind, ",")
    FileToOpen = Application.GetOpenFilename _
    (Title:="Please choose a file to import", _
    FileFilter:="Word Files *.docx (*.docx),")
    If FileToOpen = False Then Exit Sub
    Set objWord = CreateObject("Word.Application")
    '~~> Open the relevant word document
    Set objDoc = objWord.Documents.Open(FileToOpen)
    objWord.Visible = True
    Set Rng = objDoc.Content
    With Rng
        .Font.Name = "Calibri"
        .Font.Size = 11
    End With
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With