MENU

Fun & Interesting

Excel VBA Macro: Create Word Doc & Alter Text Style (Font, Size, Bold, Italicize, Underline, Color)

greggowaffles 8,528 3 years ago
Video Not Working? Fix It Now

Excel VBA Macro: Create Word Doc & Change Text Style (Font, Size, Bold, Italicize, Underline, Color). In this video, we go over how to create a word document, add text, and change the appearance of the text with our code. Code: Sub change_font() Dim objWord Dim objDoc Set objWord = CreateObject("Word.Application") Set objDoc = objWord.Documents.Add With objDoc objDoc.Styles.Add ("MyFontStyle") With .Styles("MyFontStyle").Font .Name = "Impact" .Size = 30 .Bold = False .Underline = False .Italic = True .textColor = RGB(31, 174, 225) End With End With With objWord .Selection.Style = objDoc.Styles("MyFontStyle") .Visible = True .Activate .Selection.typetext ("Hello!!!!!!!!") .Selection.typeparagraph .Selection.typetext (ThisWorkbook.Sheets("Whatever").Cells(1, 1).Text) End With End Sub #ExcelVBA #ExcelMacro

Comment