Last active
April 3, 2023 09:58
-
-
Save aspose-com-gists/41f3b1d61a73dadd899491b6e0e6af2b to your computer and use it in GitHub Desktop.
Revisions
-
aspose-com-gists revised this gist
Mar 7, 2022 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ # Load a presentation with slides.Presentation("presentation.pptm") as presentation: # Check if presentation contains VBA Project if presentation.vba_project is not None: # Print each module This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1 @@ Read the complete article on how to add, extract, and remove VBA macros in PowerPoint using Python: https://blog.aspose.com/2022/02/21/work-with-vba-macros-in-powerpoint-in-python/ -
aspose-com-gists created this gist
Mar 7, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ # Create or load a presentation with slides.Presentation() as presentation: # Create new VBA project presentation.vba_project = slides.vba.VbaProject() # Add empty module to the VBA project module = presentation.vba_project.modules.add_empty_module("Module") # Set module source code module.source_code = "Sub Test(oShape As Shape) MsgBox ""Test"" End Sub" # Create reference to <stdole> stdoleReference = slides.vba.VbaReferenceOleTypeLib("stdole", "*\\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\\Windows\\system32\\stdole2.tlb#OLE Automation") # Create reference to Office officeReference =slides.vba.VbaReferenceOleTypeLib("Office", "*\\G{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}#2.0#0#C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE14\\MSO.DLL#Microsoft Office 14.0 Object Library") # add references to the VBA project presentation.vba_project.references.add(stdoleReference) presentation.vba_project.references.add(officeReference) # Save presentation presentation.save("add-vba-macro.pptm", slides.export.SaveFormat.PPTM) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ # Load a presentation with slides.Presentation("presentation.pptm") as presentation: # check if presentation contains VBA Project if presentation.vba_project is not None: # Print each module for module in presentation.vba_project.modules: print(module.name) print(module.source_code) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ Read the complete article on how to add, extract, and remove VBA macros in PowerPoint using Python: This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ # Load a presentation with slides.Presentation("presentation.pptm") as presentation: # Remove VBA macro using index presentation.vba_project.modules.remove(presentation.vba_project.modules[0]) # Save presentation presentation.save("remove-vba-macro.pptm", slides.export.SaveFormat.PPTM)