Introduction
The examples demonstrate how to automate the following activities:
- Referencing DSO Framer Active-X control on form
- Starting Word
- Creating a new document
Background Automation is a process that allows applications to control other application for e.g. application developed using Visual Basic .NET or C# can programmatically control other applications. The automation process can be performed through the Object Model of the application which is controlled. Word exposes this programmatic functionality through an
You could invoke word document as document in word application or you could have a DSO Framer Active-X control on your form to host word document. DSO Framer Active-X control acts as an ActiveX document container for hosting Office documents (including Microsoft Word, Microsoft Excel, Microsoft PowerPoint, Microsoft Project, and Microsoft Visio documents) in a custom form or Web page. The control (Dsoframer.ocx) is lightweight and flexible, and gives developers new possibilities for using Office in a custom solution. You can find more information on DSO Framer Active-X with source code at http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q311/7/65.asp&NoWebContent=1
Â
Steps
C:\\WINNT\System32\regsvr32 Dsoframer.ocx
public Word.Document oDoc;
private
void button1_Click( object sender, System.EventArgs e){
//Remove DSO Title Bar and create a new Word document
axFramerControl1.Titlebar =
false;axFramerControl1.CreateNew("Word.Document");
axFramerControl1.Activate();
//Invoke Word properties
oDoc = (Word.Document)axFramerControl1.ActiveDocument;
oDoc.ActiveWindow.View.Type = Word.WdViewType.wdOutlineView;
oDoc.ActiveWindow.DisplayRulers =
false;oDoc.ActiveWindow.DisplayScreenTips =
false;oDoc.ActiveWindow.DisplayHorizontalScrollBar =
false;oDoc.ActiveWindow.DisplayVerticalRuler =
false;oDoc.ActiveWindow.DisplayVerticalScrollBar =
true;}
Conclusion
You can play around with all objects, properties and methods of word to control it programmatically through your code.
Â
Â
Â
Â