Long story short - I am trying to pass a string to PowerPoint from PowerShell to update a textbox on a master slide. I can do this from within PowerPoint vba, but it is completely static. As soon as I try to pass data through PowerShell to PowerPoint, I get an error that I have been unable to solve. (see here)
So instead I am attempting to do it through an Excel proxy! I already use Excel VBA to update content on PowerPoint slides, so thought this would be suitable. I currently have shapes set up in Excel, data is updated, and then this is pasted in to a PowerPoint deck, saved and closed.
I need to now extend this Excel macro with functionality that updates the textbox on the master slide. I need to translate "PowerPoint VBA" to "Excel VBA for PowerPoint", what a horrible sentence... I digress:
PowerPoint VBA
Function UpdateMasterF(message As Variant)
Dim sourceLabel As Shape
Dim curSLD As Long
curSLD = ActiveWindow.View.Slide.SlideIndex
'switch to SlideMaster
Application.Windows(1).ViewType = ppViewSlideMaster
Set sourceLabel = ActivePresentation.SlideMaster.CustomLayouts(1).Shapes("sourcelabel")
sourceLabel.TextFrame.TextRange.Text = message
'return to default
Application.Windows(1).ViewType = ppViewNormal
'set slide
ActiveWindow.Presentation.Slides(curSLD).Select
Excel VBA
Function TestPowerPoint(message As Variant, presPath As Variant)
Dim oPPTApp As Object
Dim oPPTFile As Object
Set oPPTApp = CreateObject("PowerPoint.Application")
oPPTApp.Visible = msoTrue
Set oPPTFile = oPPTApp.Presentations.Open(presPath)
' translate e.g. ApplicationWindow, ActivePresentation etc
oPPTFile.Save
oPPTFile.Close
Set oPPTFile = Nothing
oPPTApp.Quit
Set oPPTApp = Nothing
I need to be able to complete the same steps as in the PowerPoint VBA but in the Excel macro. I'm having issues finding the right names for it though. So where it says
Application.Windows(1).ViewType = ppViewSlideMaster
Can this be replaced with oPPTApp or oPPTFile? I've read through MSDN Docs and it seems to match but doesn't work.
Hopefully that's conveyed my ask! I expect most people to read and shudder at such a situation...
ActivePresentation.SlideMaster.CustomLayouts(1)...
then perhaps you don't need to? I've no idea though, I've never written to the Master. – CLRApplication.Windows(1).ViewType = ppViewSlideMaster
andApplication.Windows(1).ViewType = ppViewNormal
at all. Best of luck! – CLR