Viewing a word doc within a Windows Forms Application

I would like to display a word document within my windows form application.

Currently I am using the IE activeX control and passing it the word doc location.

There must be a more elegant solution.


Answer this question

Viewing a word doc within a Windows Forms Application

  • MAAP

    I am also experiencing the same dilema as Juma.  I am using C# .NET as well and the events never seem to fire.  From the AxDSOFramer.AxFramerControl can I get to a DSOFramer.FramerControl   Any insight into this would be greatly appreciated!

    Thanks,
    Justin

  • Kiexcolo

    Hi,

    I used the Dsoframer to embed the MS word on the web, it works fine, however whenever I go to the Print Preview mode and try to close the print priview mode and go back to the Normal view I get an error. Does anybody had the same problem, do you know a solution for that. Would appreciate any help. Regards

  • Ravi D

    I found a way to get the DSOFramer.FramerControl.  This also has various events... similar to AxDSOFramer.AxFramerControl... except they actually seem to work!

    In C# code do something like this:

    DSOFramer.FramerControl fc = new DSOFramer.FramerControl();
    fc = (DSOFramer.FramerControl)AxFramerControl1.GetOcx();
    fc.BeforeDocumentSaved += new DSOFramer._DFramerCtlEvents_BeforeDocumentSavedEventHandler(fc_BeforeDocumentSaved);

    private void fc_BeforeDocumentSaved(object Doc, string Location, ref bool Cancel)
    {
      [your code here]
    }

    It seems that for BeforeDocumentsSaved even if I assign Cancel = true... the original file still gets saved over.

    Oh well this is better than no events firing!

  • John M-W

    The DSOFramer work fine also with c#.
    1. Register dsoframer.ocx (regsvr32 "path/dsoframer.ocx")
    2. From your project in VS2003 make reference to dsoframer.ocx.
    3. Add dsoframer.ocx to your toobox and put from toolbox to winform;
    4. You got like - private AxDSOFramer.AxFramerControl axFControl;
    5. In InitializeComponent(); to open existing document use:
        axFControl.Open("C://Doc.doc",false,"Word.Document",Type.Missing,Type.Missing);
        "C://Doc.doc" - path to word document (.xls for Excel);
        false - allow editing;
        "Word.Document" - type of office application ("Excel.Sheet" or "Excel.Chart" for Excel);
        Type.Missing - user name and password if not exists.
    6.  Run your WinForm and viola!!!
    7.  Ofcourse, play with properties and other control stuff.
    8.  Create new office document - axFControl.CreateNew (some technik).
    9.  With VB.NET should be some easy.

    Best Regards,
          Peter Kirsanov  peterkirsanov@yahoo.com

  • Greg Chappell

    Hi,

    I have just dicsovered DSOFramer and am a little stuck.

    I am writing an ASP.Net application and I want to load a office doc dynamically. I do not want to have the users selecting a document. The document and path will be stored in a data base. They sill select the doc from a datagrid and that will load into the DSOFramer component.

    I have spent the last 4 hours trying to get it to work and no luck I have followed March Hare's setup up steps and still no joy. Does any one have some code example for ASP.Net. I can get it working fine in a VB.Net app no problem. 

    Any help will be greatly appreciated.

    Thanks

  • Mgrondin345

    Do you still need a code example or did my answer to your questions offline help

    -Paul

  • Ryan Pedersen

    There isn't.

    (AFAIK, at least)

  • Stephen Clegg III

    Hi,

    I've successfully loaded an excel document into the dsoFramer, But what I want to do is now add some tasks that I can run on the document from outside the dsoFramer maybe using the Excel Application objects. Save and then refresh ...

    I have got a workbook object = to the workbook in the dsoFramer
    Workbook = oFramer.ActiveDocument

    But then I cannot seem to attach the workbook to a workbooks collection(It wants a Template !)


    Any help  

    Regards

    Emilio

  • simflex

    This is something that will be added in 2.0: 
    http://www.windowsforms.net/WhidbeyFeatures/default.aspx PageID=2&ItemID=12&Cat=Controls&tabindex=4

  • DCStudios


    I tried this and still no events fired!
    Is there any additional code you may have left out of the post

  • PAANIS

    Yes there is a lot of code I left out of the post...  I only posted the code relevent to obtaing the underlying DSOFramer.FramerControl of an AxDSOFramer.AxFramerControl.

    You must have dsoframer.ocx registered.  Try the code below... let me know what error(s) you are receiving.

    Here is the code for a complete form:

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;

    namespace WindowsApplication1
    {
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private AxDSOFramer.AxFramerControl axFramerControl1;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;

    public Form1()
    {
    //
    // Required for Windows Form Designer support
    //
    InitializeComponent();

    //
    // TODO: Add any constructor code after InitializeComponent call
    //
    }

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    }

    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
    this.axFramerControl1 = new AxDSOFramer.AxFramerControl();
    ((System.ComponentModel.ISupportInitialize)(this.axFramerControl1)).BeginInit();
    this.SuspendLayout();
    // 
    // axFramerControl1
    // 
    this.axFramerControl1.Enabled = true;
    this.axFramerControl1.Location = new System.Drawing.Point(0, 0);
    this.axFramerControl1.Name = "axFramerControl1";
    this.axFramerControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axFramerControl1.OcxState")));
    this.axFramerControl1.Size = new System.Drawing.Size(552, 424);
    this.axFramerControl1.TabIndex = 0;
    this.axFramerControl1.OnFileCommand += new AxDSOFramer._DFramerCtlEvents_OnFileCommandEventHandler(this.axFramerControl1_OnFileCommand);
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(552, 429);
    this.Controls.Add(this.axFramerControl1);
    this.Name = "Form1";
    this.Text = "Form1";
    this.Load += new System.EventHandler(this.Form1_Load);
    ((System.ComponentModel.ISupportInitialize)(this.axFramerControl1)).EndInit();
    this.ResumeLayout(false);

    }
    #endregion

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    }

    private void axFramerControl1_OnFileCommand(object sender, AxDSOFramer._DFramerCtlEvents_OnFileCommandEvent e)
    {

    }

    private void Form1_Load(object sender, System.EventArgs e)
    {
    DSOFramer.FramerControl fc = (DSOFramer.FramerControl)axFramerControl1.GetOcx();
    fc.BeforeDocumentSaved += new DSOFramer._DFramerCtlEvents_BeforeDocumentSavedEventHandler(fc_BeforeDocumentSaved);
    }

    private void fc_BeforeDocumentSaved(object Document, string Location, ref bool Cancel)
    {
    //Your code here.
    }
    }
    }

  • Zac Evans

    Hi Peter,

    I am trying to use the DSOFramer control in a windows form application (C#) and for some reason I am not able to catch any events. The controls as such works but I would like to do some custom actions when those events happen. I have checked the delegate registration and it seems to be fine but the event never fires. Is there anything special I need to configure to get it working. I also noted that nobody in the forums had this problem. I would really appreciate if you can help me with it.

    Thanks and Have a great day!
    Juma

    P.S - I also noted that the parameters for the event handler were
    different from the VB6Sample application.

  • Eric McIntyre

    Hi- I downloaded the DSOFramer - but now I am not sure how to use it.
    Can you post some code examples on how to use the DSOFramer to embed an Excel document into a WinForm.

    Also - using this method - can you talk back and forth with the Excel document   Or does this only display an excel document

    Thanks so much..
    Stacie

  • Esteban27421


    There is a more elegant solution. I currently use the DsoFramer control sample to embed an Excel application into my Windows Forms application and it works well.

    Check out KB article 311765 for more information.

    http://support.microsoft.com/default.aspx scid=kb;EN-US;311765

    Also, make sure you are using Microsoft's Office PIAs if you are using Office XP to manipulate your Word instance once you have it running:

    http://www.microsoft.com/downloads/details.aspx FamilyId=C41BD61E-3060-4F71-A6B4-01FEBA508E52&displaylang=en


    Good luck!

    -Paul

  • Viewing a word doc within a Windows Forms Application