Using vb.net, how do I center a paragraph in MS-Word horizontally and vertically?

Seems like this should be a simple request, but I haven't been able to find anything online to help me yet. I'm using Visual Studio 2015 Community and writing in vb.net with a reference to Microsoft.Office.Interop.Word. I am creating a word document (only two lines) with the code below and saving it. My problem is that I want the two lines centered both vertically and horizontally. My code shows a couple of the things I've tried without success. Also, how do I get a line break between the two lines so I am only inserting one paragraph? As you can tell, I'm very new to this so please be specific with your answers. Thanks.

    Private Sub CreateTitlePage2()

        Dim wdApp As Microsoft.Office.Interop.Word.Application = New Microsoft.Office.Interop.Word.Application
        Dim wdDoc As Microsoft.Office.Interop.Word.Document = New Microsoft.Office.Interop.Word.Document
        Dim wdPara1 As Microsoft.Office.Interop.Word.Paragraph
        Dim wdPara2 As Microsoft.Office.Interop.Word.Paragraph

        wdDoc.Application.Visible = False

        wdPara1 = wdDoc.Content.Paragraphs.Add
        wdPara1.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter
        wdPara1.Range.Font.Bold = True
        wdPara1.Range.Text = "BINDER DOCUMENT"
        wdPara1.Range.InsertParagraphAfter()

        wdPara2 = wdDoc.Content.Paragraphs.Add
        wdPara2.Format.SpaceBefore = WdVerticalAlignment.wdAlignVerticalCenter
        wdPara2.Range.Font.Bold = True
        wdPara2.Range.Text = "Created:    " + formattedDate2
        wdPara2.Range.InsertParagraphAfter()

        wdDoc.SaveAs(binderNameDoc)
        wdDoc.Close()
        wdApp.Quit()

    End Sub
johnrosshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
try...
...
wdPara1 = wdDoc.Content.Paragraphs.Add
wdPara1.Range.InsertParagraphAfter()
wdPara1.Range.Text = "BINDER DOCUMENT"
wdPara1.Range.Font.Bold = True
wdPara1.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter
        
wdPara2 = wdDoc.Content.Paragraphs.Add
wdPara2.Range.InsertParagraphAfter()
wdPara2.Range.Text = "Created:    " + formattedDate2
wdPara2.Range.Font.Bold = True
wdPara2.Format.SpaceBefore = WdVerticalAlignment.wdAlignVerticalCenter
...

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
johnrosshAuthor Commented:
Thanks Ryan. This worked well for centering horizontally but not vertically. For the vertical alignment, I found my problem was trying to align the paragraph rather than the whole page. I've got it working now.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.