Excel VBA: установка стиля и размера шрифта при добавлении текста в MS-Word

Я хочу создать документ Word, используя Excel VBA, и добавить текст с различными стилями шрифтов и размеров. Вот мой код:

Sub CreateNewWordDoc()
    Dim wrdDoc As Word.Document
    Dim wrdApp As Word.Application
    Set wrdApp = CreateObject("Word.Application")
    Set wrdDoc = wrdApp.Documents.Add

    Dim charStart As Long
    Dim charEnd As Long

    With wrdDoc
        For i = 1 To 3
            charStart = wrdApp.Selection.Start
            .Content.InsertAfter (" some text")
            charEnd = wrdApp.Selection.End
            If i = 1 Then
                'set the text range (charStart,charEnd) to e.g. Arial, 8pt
            Else
                If i = 2 Then
                    'set the text range (charStart,charEnd) to e.g. Calibri, 10pt
                Else
                    'set the text range (charStart,charEnd) to e.g. Verdana, 12pt
                End If
            End If
        Next i
        .Content.InsertParagraphAfter
        .SaveAs ("testword.docx")
        .Close ' close the document
    End With
    wrdApp.Quit
    Set wrdDoc = Nothing
    Set wrdApp = Nothing
End Sub

Как определить стиль и размер шрифта на лету в приведенном выше операторе if-else?

Ответы на вопрос(1)

Ваш ответ на вопрос