Advertisment

Display Web forms using DSO Framer Active-X

author-image
CIOL Bureau
Updated On
New Update

Introduction





The examples demonstrate how to automate the following activities:

Advertisment



  • 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

object model library. The object model is a collection of classes and methods that serve as counterparts to the logical components of Word. Automation to Word allows you to perform actions such as creating & opening documents, adding text to documents, saving documents in different formats, handling e-mail, mail merge, and formatting documents and much more. With Word and other Microsoft Office applications, nearly all of the functionalities which you would perform manually through the user interface are available to control through programmatically by using automation. You would find various objects such as Application, Document, Paragraph, Range etc., each of which contain the functionality of that component in Word.



Advertisment

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



 



Advertisment

Steps



  • Download DSO Framer from above link and register DSOFramer.ocx into system directory using regsvr32 command.


  • C:\\WINNT\System32\regsvr32 Dsoframer.ocx



  • On successful registration you would get message dialog.


  • Add DSO Framer Active-X control on your form through customize toolbox window as shown below.






  • Drag and drop DSO from toolbox on your form and resize as per requirement.


  • Now add reference for Word Object Library 11.0 from add reference on solution explorer. Here I am using Word 2003, so object library version is 11.0. See figure






  • You can see all added reference on solution explorer as shown in figure. Two reference has been added for DSO framer (brown circle) and three libraries for Office & Word (red circle).






  • Define a variable for word document in public section of form as


  • Advertisment
    public Word.Document oDoc;

  • Add a button to form and "Launch Word" as its text, on click event it would open a new word document.


  • Add following code for button click event


  • private

    Advertisment
    void button1_Click(
    Advertisment
    object sender, System.EventArgs e)

    {



    //Remove DSO Title Bar and create a new Word document

    Advertisment

    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;

    }



  • Now you can add text, format it, send mail do all functionalities.


  • You can control all word functionalities to be made available or unavailable programmatically through code with all available objects, properties & Methods of word.
  • Conclusion

    You can play around with all objects, properties and methods of word to control it programmatically through your code.



     



     



     



     

    tech-news