Microsoft Office Word document

Need a little help here.

I am generating a word document and having a little trouble understanding the separation of paragraphs.

This code generates a word document (screen shot attached) and I am having issues formatting the paragraphs to the left.  the top paragraph and the bitmap I import should be centered.  the paragraph below (in the red box) should be shifted to the left.

                object oMissing = System.Reflection.Missing.Value;
                object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */

                //Start Word and create a new document.

                // Get the Word application object.
                Word._Application oWord = new Word.Application();

                //Set animation status for word application
                oWord.ShowAnimation = false;

                //Make Word visible (optional)
                oWord.Visible = true;

                // Create the Word document.
                object missing = Type.Missing;
                Word._Document word_doc = oWord.Documents.Add(ref missing, ref missing, ref missing, ref missing);

                // Set the Range to the first paragraph. 
                Word.Range rng = word_doc.Paragraphs[1].Range;

                //Set Text and Alignment properties
                rng.Font.Size = 12;
                rng.Font.Name = "Arial";
                rng.Underline = WdUnderline.wdUnderlineSingle;
                rng.Font.Bold = 1;
                rng.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
                rng.ParagraphFormat.SpaceAfter = 0;
                rng.ParagraphFormat.SpaceBefore = 0;
                rng.ParagraphFormat.LineSpacing = 12;
                rng.Text = txtStationName.Text + " TEST EQUIPMENT" + Environment.NewLine + "TEST TEST TEST";
                
                rng.InsertParagraphAfter();

               //Insert a paragraph as a spacer
                Word.Paragraph oPara2;
                object oRng1 = word_doc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                oPara2 = word_doc.Content.Paragraphs.Add(ref oRng1);
                oPara2.Range.Text = " ";
                oPara2.Format.SpaceAfter = 6;
                //oPara2.Format.Borders.Enable;// = true;// = 1;
                oPara2.Range.InsertParagraphAfter();
                
                Word.Paragraph concept = word_doc.Paragraphs.Add();

                // Add BitMap to WORD Document
                Bitmap croppedBitmap = new Bitmap(pictureBox1.Image);
                croppedBitmap = croppedBitmap.Clone(new System.Drawing.Rectangle(0, 0, picBoxSize_X, picBoxSize_Y), System.Drawing.Imaging.PixelFormat.DontCare);

                Clipboard.SetImage(croppedBitmap);      
                concept.Range.InsertParagraphAfter();
                concept.Range.Select();
                oWord.Selection.Paste();


                //Insert a paragraph at the end of the document.
                Word.Paragraph oPara3;
                object oRng = word_doc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                oPara3 = word_doc.Content.Paragraphs.Add(ref oRng);
                oPara3.Format.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;
                oPara3.Range.Text = "Notes: – TEST Equipment TEST TEST TEST ";
                oPara3.Format.SpaceAfter = 6;
                oPara3.Range.InsertParagraphAfter();

Open in new window


Pointers anyone...

Thanks
JedidiaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Rgonzo1971Commented:
Hi,

Why don't you simply format after inserting the text

      oPara3.Range.Text = "Notes: – TEST Equipment TEST TEST TEST ";
      oPara3.Format.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;

Open in new window

Regards

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
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
C#

From novice to tech pro — start learning today.