Comments (3)
Hi @avipek10!
To embed files into PowerPoint presentation, you can use the following function:
https://python-pptx.readthedocs.io/en/stable/api/shapes.html#pptx.shapes.shapetree.SlideShapes.add_ole_object
Here is a basic example to do so:
from pptx import Presentation
from pptx.util import Inches
prs = Presentation()
slide_layout = prs.slide_layouts[5] # Title and Content layout
slide = prs.slides.add_slide(slide_layout)
slide.shapes.title.text = "Adding h3d file"
path_to_h3d = "test.h3d"
slide.shapes.add_ole_object(
object_file=path_to_h3d, prog_id="Package", left=Inches(2), top=Inches(2)
)
prs.save("add_h3d.pptx")
Further improvement possibilities:
- When .h3d is inserted by drag-and-drop, the
prog_id
is set toPackage
as the application is unknown, but if you know theprog_id
for HyperWorks, you can replace that. - You can add
icon_file
as well for better aesthetics.
from python-pptx.
Thank for the response.
It did embed something but when double click inside the power point I get an error message.
from python-pptx.
sorry it did not upload the picture last time.
from python-pptx.
Related Issues (20)
- Cant put the hyperlink on the chart
- Save Slide as Image HOT 2
- Local PDF to PowerPoint Converter with LLM Summarization HOT 1
- Is it possible to add support for "/select,file:///..." URIs? HOT 3
- Convert PPTX slide to Image HOT 1
- Line char None values
- How to set shink in sharp when text box overflow in Python pptx HOT 1
- Fit shape to text?
- Hide a shape HOT 2
- ValueError: value must be in range 256 to 2147483647 inclusive, got 2147483648 - when adding slide HOT 13
- MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE attribute does not take effect HOT 4
- Removing video results in corrupted file. HOT 6
- Create multiple slides with concurrent.futures HOT 1
- run function on click HOT 1
- How to access and create media objects HOT 8
- copying slide-masters HOT 2
- Make xlsxwriter an optional dependency HOT 4
- There is a bug for load image under the package "langchain.document_loaders import UnstructuredImageLoader" HOT 1
- Add OLE shapes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-pptx.