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();
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE