Reputation: 11
I Have excel workbook which maintains data of my customers Like address & Due amount. I am writing a VBA code in excel which will generate letter to each of the customer for the due amounts. I cannot use mailmerge because of the complexity of the letter. I am using following codes to add paragraphs
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add
wrdDoc.content.InsertAfter "----------"
wrdDoc.content.InsertParagraphAfter
Now I need to change alignment of paragraphs. The paragraphs in body of letter are to be justified while some paragraphs like subject line are to be center aligned. I tried this code but its not working
1.
wrdDoc.Paragraphs(8).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
also
2.
wrdDoc.Paragraphs(8).Alignment = wdAlignParagraphCenter
What is the correct way doing this?
Regards Shekhar
Upvotes: 0
Views: 29794
Reputation: 91
This worked for me:
objselection.Paragraphs.Alignment = 3
Numbers:
3 Justify 2 Center 1 Right Justify
Upvotes: 4