AddOleObjectFrame

AddOleObjectFrame(float, float, float, float, IOleEmbeddedDataInfo)

Adds a new OLE object to the end of a collection.

public IOleObjectFrame AddOleObjectFrame(float x, float y, float width, float height, 
    IOleEmbeddedDataInfo dataInfo)
ParameterTypeDescription
xSingleX coordinate of a new OLE frame.
ySingleY coordinate of a new OLE frame.
widthSingleWidth of a new OLE frame.
heightSingleHeight of a new OLE frame.
dataInfoIOleEmbeddedDataInfoEmbedded data info IOleEmbeddedDataInfo.

Return Value

Created OLE object.

Examples

The following examples shows how to adding OLE Object Frames to Slides of PowerPoint Presentation.

[C#]
// Instantiates the Presentation class that represents the PPTX file
using (Presentation pres = new Presentation())
{
    // Accesses the first slide
    ISlide sld = pres.Slides[0];
    // Loads an excel file to stream
    MemoryStream mstream = new MemoryStream();
    using (FileStream fs = new FileStream("book1.xlsx", FileMode.Open, FileAccess.Read))
    {
        byte[] buf = new byte[4096];
        while (true)
        {
            int bytesRead = fs.Read(buf, 0, buf.Length);
            if (bytesRead <= 0)
                break;
            mstream.Write(buf, 0, bytesRead);
        }
    }
    // Creates a data object for embedding
    IOleEmbeddedDataInfo dataInfo = new OleEmbeddedDataInfo(mstream.ToArray(), "xlsx");
    // Adds an Ole Object Frame shape
    IOleObjectFrame oleObjectFrame = sld.Shapes.AddOleObjectFrame(0, 0, pres.SlideSize.Size.Width,
        pres.SlideSize.Size.Height, dataInfo);
    //Writes the PPTX file to disk
    pres.Save("OleEmbed_out.pptx", SaveFormat.Pptx);
}

See Also


AddOleObjectFrame(float, float, float, float, string, string)

Adds a new OLE object to the end of a collection.

public IOleObjectFrame AddOleObjectFrame(float x, float y, float width, float height, 
    string className, string path)
ParameterTypeDescription
xSingleX coordinate of a new OLE frame.
ySingleY coordinate of a new OLE frame.
widthSingleWidth of a new OLE frame.
heightSingleHeight of a new OLE frame.
classNameStringName of an OLE class.
pathStringPath to the linked file.

Return Value

Created OLE object.

See Also