ActiveX
Contents
[
Hide
]
Demonstrates how to add, access, remove, and configure ActiveX controls in a presentation using Aspose.Slides for PHP via Java.
Add an ActiveX Control
Insert a new ActiveX control.
function addActiveX() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Add a new ActiveX control.
$control = $slide->getControls()->addControl(ControlType::WindowsMediaPlayer, 50, 50, 100, 50);
$presentation->save("activex.pptm", SaveFormat::Pptm);
} finally {
// Dispose the presentation.
$presentation->dispose();
}
}
Access an ActiveX Control
Read information from the first ActiveX control on the slide.
function accessActiveX() {
$presentation = new Presentation("activex.pptm");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Access the first ActiveX control.
$control = $slide->getControls()->get_Item(0);
echo "Control Name: " . $control->getName() . PHP_EOL;
} finally {
// Dispose the presentation.
$presentation->dispose();
}
}
Remove an ActiveX Control
Delete an existing ActiveX control from the slide.
function removeActiveX() {
$presentation = new Presentation("activex.pptm");
try {
$slide = $presentation->getSlides()->get_Item(0);
if (java_values($slide->getControls()->size()) > 0) {
// Remove the first ActiveX control.
$slide->getControls()->removeAt(0);
}
$presentation->save("activex_removed.pptm", SaveFormat::Pptm);
} finally {
// Dispose the presentation.
$presentation->dispose();
}
}
Set ActiveX Properties
Configure several ActiveX properties.
function setActiveXProperties() {
$presentation = new Presentation("activex.pptm");
try {
$slide = $presentation->getSlides()->get_Item(0);
// Assuming the first control is the one we added.
$control = $slide->getControls()->get_Item(0);
// Configure properties.
$control->getProperties()->set_Item("Caption", "Click Me");
$control->getProperties()->set_Item("Enabled", "true");
$presentation->save("activex_properties.pptm", SaveFormat::Pptm);
} finally {
// Dispose the presentation.
$presentation->dispose();
}
}