Excel VBA Macro: Create Word Doc & Have Mutliple Text Styles (in the Same File) Heading & SubHeading

  Рет қаралды 2,050

greggowaffles

greggowaffles

Жыл бұрын

Excel VBA Macro: Create Word Doc & Have Mutliple Text Styles (in the Same File) Heading & SubHeading. In this video, we go over how to include multiple text styles in the same word doc. We use our code to alter the text font type, size, color, bold, italicize, and underline, so that we can create headings and sub headings in our word document.
Code:
Sub multiple_text_styles()
Dim objWord
Dim objDoc
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
With objDoc
objDoc.Styles.Add ("MyHeading")
objDoc.Styles.Add ("MySubHeading")
objDoc.Styles.Add ("MyParagraph")
With .Styles("MyHeading").Font
.Name = "Times"
.Size = 30
.Bold = True
.Underline = True
.Italic = False
.textColor = RGB(165, 0, 33)
End With
With .Styles("MySubHeading").Font
.Name = "Arial"
.Size = 20
.Bold = True
.Underline = False
.Italic = True
.textColor = RGB(255, 80, 80)
End With
With .Styles("MyParagraph").Font
.Name = "Times"
.Size = 100
.Bold = False
.Underline = False
.Italic = False
.textColor = RGB(0, 0, 0)
End With
End With
With objWord
.Visible = True
.Activate
With .Selection
.Style = objDoc.Styles("MyHeading")
.typetext ("Introduction")
.typeparagraph
.Style = objDoc.Styles("MySubHeading")
.typetext (ThisWorkbook.Sheets("Sheet1").Cells(1, 1).Text)
.typeparagraph
.Style = objDoc.Styles("MyHeading")
.typetext (ThisWorkbook.Sheets("Sheet1").Cells(2, 1).Text)
End With
End With
End Sub
#ExcelVBA #ExcelMacro

Пікірлер: 6
@KatLeFevre
@KatLeFevre Жыл бұрын
This was really helpful! Your sounds is great, the pacing is great, and this video made something click in my head that helped me get further along on a work VBA project that I've been struggling with for months. (I'm learning slowly!)
@greggowaffles
@greggowaffles Жыл бұрын
So glad to hear that!! I hope your VBA project goes well!! 😊
@drewgossage8842
@drewgossage8842 Жыл бұрын
Thanks for sharing mate 👍
@greggowaffles
@greggowaffles Жыл бұрын
Thanks for watching!
@gruhby9546
@gruhby9546 Жыл бұрын
Great video! How could I modify pages to be horizontal vs vertical?
@greggowaffles
@greggowaffles Жыл бұрын
thanks! you can use this: objDoc.PageSetup.Orientation = 1
Excel VBA Macro: Resize Range (Table) Pasted As Image In Email Body
14:13
Excel VBA Macro: Create Word Document & Add Table (Static Range)
9:32
Iron Chin ✅ Isaih made this look too easy
00:13
Power Slap
Рет қаралды 36 МЛН
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 10 МЛН
Fast and Furious: New Zealand 🚗
00:29
How Ridiculous
Рет қаралды 39 МЛН
Looks realistic #tiktok
00:22
Анастасия Тарасова
Рет қаралды 106 МЛН
How To Copy Multiple Excel Tables To Word Using VBA
25:10
Sigma Coding
Рет қаралды 7 М.
How To Work With Paragraphs In Word VBA
16:28
Sigma Coding
Рет қаралды 13 М.
How to Get List of File Names in a Folder using Excel
5:40
Excel Weez
Рет қаралды 6 М.
Excel VBA Introduction Part 29.3 - Outlook Emails using the Word Editor
20:23
Insert Header And Footer To Word Documents With VBA
6:06
Jie Jenn
Рет қаралды 7 М.
Excel VBA Macro: Send Multiple Emails (with Multiple Attachments)
12:09
How to use Custom Types To Write Ultra Fast VBA code
12:51
Excel Macro Mastery
Рет қаралды 29 М.
Extract Specific Data from MS Word into Excel with VBA
10:56
Dinesh Kumar Takyar
Рет қаралды 32 М.
Iron Chin ✅ Isaih made this look too easy
00:13
Power Slap
Рет қаралды 36 МЛН