I'm stumped and I feel like I've got to be missing something dumb...
This macro is intended to call and run a macro whose code is contained in another file and "apply" the macro to the open presentation (from which the initial macro was run). I'm getting a Compile error: Method or data member not found on the second to last line. When I comment that line out, the code runs properly but applies the macro to the wrong presentation.
Any ideas?
Thanks in advance, Joe
Function IsPresentationOpen(Name As String) As Boolean
Dim codePres As Presentation
On Error Resume Next
Set codePres = Application.Presentations.Item(Name)
IsWorkBookOpen = (Not codePres Is Nothing)
End Function
Sub Run_Macro()
Dim BriefingTemplate As Presentation
Set BriefingTemplate = Application.ActivePresentation
'Open Joe's Code Workbook
Dim xRet As Boolean
xRet = IsPresentationOpen("CODE.potm")
If xRet Then
Else
Presentations.Open "Direcory\CODE.potm"
End If
'Run Macro
BriefingTemplate.Activate '<<This is the line w/ the error
Application.Run ("'CODE.potm'!Macro"), BriefingTemplate
End Sub
Sub a_RunAll_PM(BriefingTemplate As Presentation)
BriefingTemplate.Activate
Call a_Scorecards_PM
Call CurrentTemps_PM
Call RadarSat_PM
Call Severe_PM
Call Day1_PM
Call Day2
Call JetStream_PM
Call Operational_Impact_PM
Call D1_Headlines_PM
Call D2_Headlines
End Sub
Sub a_Scorecards_PM()
Dim oPic As Shape
Set oPic = ActivePresentation.Slides(1).Shapes.AddPicture( _
FileName:="H:\Weather Briefs\Daily Ops Scorecards\SWA_Page_1.jpg", _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, Left:=0, Top:=0, _
Width:=720, Height:=540)
ActivePresentation.Slides(1).Copy
ActivePresentation.Slides.Paste 24
End Sub
IsPresentationOpen
is always returningFalse
because you never assign a return value.Presentation
object does not have anActivate
method - which is why it is saying that the method does not exist. TBH, I suspect that your problem lies with the code in "Macro", which is probably not written in such a way as to update the correct presentation. So it would probably be useful if you asked us to help you fix that code.xRet
and usingif not IsPresentationOpen("CODE.potm") then Presentations.Open "Direcory\CODE.potm"
Macro
's code so that it does its work on whichever presentation you need it to. You are passing the presentation you want to update (i.e.BriefingTemplate
) to the macro as a parameter - if you show the code for that macro to us we can help you fix it so that it updates the presentation you passed.