Office 2003 Word automation C# help needed for Autoshapes manipula

  • Thread starter Autoshapes word autmation
  • Start date
A

Autoshapes word autmation

Can anyone provide details to show how Autoshapes creation/resize (Word
Office 2003)etc can be automated using C# (.Net framework 2.0). It will be
great if anybody can provide urls and code samples for the same. I am new to
word automation.

Thanks in Advance,
Rajeev
 
A

Autoshapes word autmation

Hello,
After doing some research I got it myself.
Sample for creating an autoshape rectangle posted below.

//used the name spaces
using Word = Microsoft.Office.Interop.Word;
using Core = Microsoft.Office.Core;


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

//Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref
oMissing, ref oMissing);

// Code to create an autoshape rectangle
Word.Shape shpRect;
object orRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
orRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;

shpRect =
oDoc.Shapes.AddShape((int)Core.MsoAutoShapeType.msoShapeRectangle, 100, 100,
150, 150, ref orRng);


shpRect.Line.Weight = 2;



I was able to create a rectangle using this.

Cheers,
Rajeev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top