wordpress hit counter
Welcome to OpenXML Developer Sign in | Join | Help

(Info)Adding an ActiveX control to an Office Document

Last post 06-06-2007, 9:24 AM by Geoff. 1 replies.
Sort Posts: Previous Next
  •  09-07-2006, 4:39 AM 628

    (Info)Adding an ActiveX control to an Office Document

    The post is to give some information on ActiveXControls in Office document.
    An ActiveX control can be added,say in a Word document from the Controls tag,in the developer ribbon.
    This can also be done from the packaging structure.
    for example if a text box is to be included in the document,
    in 'document.xml',include this part of xml in the location you want the control to appear,

    <w:p>

           <w:r>
     
                <w:object>
     
                      <w:ocx r:id="rId12" w:id="TextBox1" w:name="TextBox1" w:shapeid="_x0000_i1032" w:class="shape" w:w="96" w:h="26" />   
     
                </w:object>
       
          </w:r>
     
        </w:p>
     
    The properties of the control included in the document are described in ,
    ' word\activeX\activeXx.xml ',i.e. each control has a separate activeX xml file describing it.
    These properties can be edited accordingly.
       The contents of activeX1.xml would be,
     
    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
       <ax:ocx ax:classid="{978C9E23-D4B0-11CE-BF2D-00AA003F40D0}" ax:persistence="persistPropertyBag" xmlns:ax="http://schemas.openxmlformats.org/officeDocument/2006/2/activeX" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
      <ax:ocxPr ax:name="ForeColor" ax:value="0" />
      <ax:ocxPr ax:name="BackColor" ax:value="16777215" />
      <ax:ocxPr ax:name="Caption" ax:value="Name" />
      <ax:ocxPr ax:name="Size" ax:value="2540;635" />
      <ax:ocxPr ax:name="FontName" ax:value="Calibri" />
      <ax:ocxPr ax:name="FontHeight" ax:value="225" />
      <ax:ocxPr ax:name="FontCharSet" ax:value="0" />
      <ax:ocxPr ax:name="FontPitchAndFamily" ax:value="2" />
      </ax:ocx>
     
          Here the attribute,'classid' would be an unique identifier,and the attribute,' persistance'  specifies the method used to store properties for this ActiveX control.If 'ocxPr' tags are contained in the parent 'ocx' element, this value must be set to 'persistPropertyBag', otherwise, the 'ocx' element must specify a binary part which contains the control's properties as a binary stream.
     
         Set the corresponding relationship in the document relationship file
     
    <Relationship Id="rId12" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/activeXControl" Target="activeX/activeX1.xml" />
     
        Set the content types as well.
     
    <Override PartName="/word/activeX/activeX1.xml" ContentType="application/vnd.openxmlformats-officedocument.activeX+xml" />
     
       Regards,
       Vijayeta
     
     
     
     
     
     

     

  •  06-06-2007, 9:24 AM 1636 in reply to 628

    Re: (Info)Adding an ActiveX control to an Office Document

    Could someone provide instructions or an example of how to add an ActiveX control in an Office Document where the control has its own XML schema -- i.e. the properties of the control are saved as an XML file/stream rather than name/value pairs in a persistPropertyBag. We tried adding a name/value pair where the name was xmlProperties and the value was an encoded version of the XML properties. This works, but seems ugly. Is it possible to make the XML properties of a control a separate part in the package that is a child to the XML part for the control itself, sort of how a PNG image is a child part of a vmlDrawing.vml part? If yes, how does the control get access to read and write its property part in the package?

    Thanks,

    Geoff

View as RSS news feed in XML