ActiveX
Contents
[
Hide
]
This article demonstrates how to add, access, remove, and configure ActiveX controls in a presentation using Aspose.Slides for Node.js via Java.
Add an ActiveX Control
Add a new ActiveX control to a slide.
function addActiveX() {
let presentation = new aspose.slides.Presentation();
try {
let slide = presentation.getSlides().get_Item(0);
// Add a new ActiveX control.
let control = slide.getControls().addControl(aspose.slides.ControlType.WindowsMediaPlayer, 50, 50, 100, 50);
presentation.save("activex.pptm", aspose.slides.SaveFormat.Pptm);
} finally {
presentation.dispose();
}
}
Access an ActiveX Control
Read information from the first ActiveX control on the slide.
function accessActiveX() {
let presentation = new aspose.slides.Presentation("activex.pptm");
try {
let slide = presentation.getSlides().get_Item(0);
if (slide.getControls().size() > 0) {
// Access the first ActiveX control.
let control = slide.getControls().get_Item(0);
console.log("Control Name:", control.getName());
console.log("Value:", control.getProperties().get_Item("Value"));
}
} finally {
presentation.dispose();
}
}
Remove an ActiveX Control
Delete an existing ActiveX control from the slide.
function removeActiveX() {
let presentation = new aspose.slides.Presentation("activex.pptm");
try {
let slide = presentation.getSlides().get_Item(0);
if (slide.getControls().size() > 0) {
// Remove the first ActiveX control.
slide.getControls().removeAt(0);
}
presentation.save("activex_removed.pptm", aspose.slides.SaveFormat.Pptm);
} finally {
presentation.dispose();
}
}
Set ActiveX Properties
Configure several ActiveX properties.
function setActiveXProperties() {
let presentation = new aspose.slides.Presentation();
try {
let slide = presentation.getSlides().get_Item(0);
if (slide.getControls().size() > 0) {
let control = slide.getControls().get_Item(0);
control.getProperties().set_Item("Caption", "Click Me");
control.getProperties().set_Item("Enabled", "true");
}
presentation.save("activex_properties.pptm", aspose.slides.SaveFormat.Pptm);
} finally {
presentation.dispose();
}
}