AddOleObjectFrame

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

Creates a new OLE object frame and adds it to the end of the shape collection.

public IOleObjectFrame AddOleObjectFrame(float x, float y, float width, float height, 
    IOleEmbeddedDataInfo dataInfo)
ParameterTypeDescription
xSingleThe x-coordinate of the new OLE frame, in points.
ySingleThe y-coordinate of the new OLE frame, in points.
widthSingleThe width of the new OLE frame, in points.
heightSingleThe height of the new OLE frame, in points.
dataInfoIOleEmbeddedDataInfoThe information about the embedded OLE data (IOleEmbeddedDataInfo).

Return Value

The newly created IOleObjectFrame.

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)

Creates a new OLE object frame and adds it to the end of the shape collection.

public IOleObjectFrame AddOleObjectFrame(float x, float y, float width, float height, 
    string className, string path)
ParameterTypeDescription
xSingleThe x-coordinate of the new OLE frame, in points.
ySingleThe y-coordinate of the new OLE frame, in points.
widthSingleThe width of the new OLE frame, in points.
heightSingleThe height of the new OLE frame, in points.
classNameStringThe class name of the OLE object.
pathStringThe path to the linked file.

Return Value

The newly created IOleObjectFrame.

See Also