Aspose::Words::Drawing::OlePackage class

OlePackage class

Allows to access OLE Package properties. To learn more, visit the Working with Ole Objects documentation article.

class OlePackage : public System::Object

Methods

MethodDescription
get_DisplayName() constGets or sets OLE Package display name.
get_FileName() constGets or sets OLE Package file name.
GetType() const override
Is(const System::TypeInfo&) const override
set_DisplayName(System::String)Setter for Aspose::Words::Drawing::OlePackage::get_DisplayName.
set_FileName(System::String)Setter for Aspose::Words::Drawing::OlePackage::get_FileName.
static Type()

Examples

Shows how insert an OLE object into a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

// OLE objects allow us to open other files in the local file system using another installed application
// in our operating system by double-clicking on the shape that contains the OLE object in the document body.
// In this case, our external file will be a ZIP archive.
ArrayPtr<uint8_t> zipFileBytes = System::IO::File::ReadAllBytes(DatabaseDir + u"cat001.zip");

{
    auto stream = MakeObject<System::IO::MemoryStream>(zipFileBytes);
    SharedPtr<Shape> shape = builder->InsertOleObject(stream, u"Package", true, nullptr);

    shape->get_OleFormat()->get_OlePackage()->set_FileName(u"Package file name.zip");
    shape->get_OleFormat()->get_OlePackage()->set_DisplayName(u"Package display name.zip");
}

doc->Save(ArtifactsDir + u"Shape.InsertOlePackage.docx");

See Also