Automating MS Word using VBA

TheShaunMichael

Board Regular
Joined
Oct 24, 2009
Messages
57
Hi All,

Am working on some vba to essentially create a Word document. I've gotten fairly proficient with VBA in the confines of MS Excel and know little to nothing about how to make it work inside of a word document.

I've managed to get a new document to open and text on the page. The following is an excerpt of the code.

With wrdDoc

.Content.InsertAfter "Schedule of Services"
.Content.InsertParagraphAfter
.Content.InsertParagraphAfter
.Content.InsertAfter "Blah Blah Blah"
.Content.InsertParagraphAfter
.Content.InsertParagraphAfter
.Content.InsertAfter "Blah Blah blah"
.Content.Style = "No Spacing"
.Content.Font.Name = "HelveticaNeue Light"

End With

This creates the following:

Schedule of Services

Blah Blah Blah

Blah Blah Blah

(in the font HelveticaNeue Light)

My question is how do i bold and make larger the first line "Schedule of services" - or how to I control the font for a specific paragraph?

Secondly, is the code i'm using the best way to get this outcome?

Third, how would I go about setting up a basic 3 row x 5 column table with specific items in each cell.

Thank you all!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Untested bu might help? Dave
Code:
'inserts at selection
With wrdDoc
.TypeText Text:="Schedule of Services" ' 1 paragraph
'.TypeParagraph to insert blank paragraph
End With
'change paragraph number to suit
With wrdDoc.paragraphs(1).Range.Font
.Name = "HelveticaNeue Light"
.Size = 13
.Bold = True
End With
 
Upvote 0

Forum statistics

Threads
1,215,836
Messages
6,127,173
Members
449,368
Latest member
JayHo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top