You must Sign In to post a response.
  • Category: ASP.NET

    How to read value of activex control from word 2010 docx in c#

    i need to retrieve value of textbox(activex control) in word 2010 docx file using open xml sdk in c#.
  • #769169
    You can add ActiveX controls to the text layer by click the control on the Control Toolbox and use given procedure switches

    public void OpenDocument(string sMyFileName,string sAppType)
    {
    sFileName = sMyFileName;


    if (acWord == null && sAppType=="W")
    { acWord = new Microsoft.Office.Interop.Word.ApplicationClass(); }

    if (wDocument != null) { try { CloseAndSave(sAppType); } catch { } }


    if (iWindow == 0 && sAppType == "W") { iWindow = FindWindow("Opusapp", null); }

    if (iWindow != 0)
    {
    SetParent(iWindow, this.Handle.ToInt32());

    object oFileName = sFileName;
    object oReadOnly = false;
    object oIsVisible = true;
    object oMissing = System.Reflection.Missing.Value;

    try
    {
    if (iWindow == 0) { throw new Exception(); }
    if (sAppType == "W")
    {
    if (acWord.Documents == null && sAppType == "W") { throw new Exception(); }

    if (acWord != null && acWord.Documents != null && sAppType == "W")
    { wDocument = acWord.Documents.Open(ref oFileName, ref oMissing,
    ref oReadOnly, ref oMissing, ref oMissing, ref oMissing,
    ref oMissing, ref oMissing, ref oMissing, ref oMissing,
    ref oMissing, ref oIsVisible, ref oMissing, ref oMissing,
    ref oMissing, ref oMissing); }

    if (wDocument == null && sAppType == "W") { throw new Exception(); }
    }
    /
    catch { }
    try
    {
    if (sAppType == "W")
    {
    acWord.Visible = true;
    acWord.Activate();
    }

    SetWindowPos(iWindow, this.Handle.ToInt32(), 0, 0, this.Bounds.Width,
    this.Bounds.Height, (0x4 | 0x2 | 0x20));

    OnResize(new EventArgs());

    }
    catch { MessageBox.Show("Error..."); }
    this.Parent.Focus();
    }

  • #769171
    i needs solution using open xml sdk in c#.


Sign In to post your comments