I have this macro in an automatically created data file (part of the creation is inserting and running the macro). I want to open a template file and then need to run a PPT macro that takes in the excel data file name. The one that called the macro (data1.xlsm) I have this but can't figure out the macro call with the file name.
Dim PPTObj As Object
Set PPTObj = CreateObject("PowerPoint.application")
With PPTObj
.Presentations.Open Filename:="C:\Presentations\Company\Template.pptm"
.Run "Template.pptm!MainMacro"
End With
.Run "Template.xlsm!MainMacro(filename)" is what I am looking for.
Maybe the other direction is to get the object in PPT. But how do I get the data file name/path without knowing it beforehand?
Set wb - getobject(openwexcelfile)
Since another program (not office) is creating the data file, I do not know it's name or directory, but it is the file calling the powerpoint macro and it will be open.
Thanks for any insight.
Thanks Comintern for the insight. Here is the final solution. The sleep is to allow PPT App to open before trying to run the macro.
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub auto_open()
fname = ActiveWorkbook.Name
Path = ActiveWorkbook.Path
Dim PPTObj As Object
Set PPTObj = CreateObject("PowerPoint.application")
PPTObj.Presentations.Open Filename:="C:\presentation\Template.pptm"
Sleep (3000)
PPTObj.Run "Template.pptm!Main", fname, Path
End Sub