[RESOLVED] PowerPoint2010 - Open userform if file name contains
Hello,
I am trying to come up with a vba code in PowerPoint 2010 that will execute when a particular file is open.
What would the code be to check if the opened file name contains a particular set of words like "Analyze Data"? Prior to this name there will be a date like "January-18", but this will change monthly (obviously) and there may be different versions afterward like "v4.pptm".
Something like:
Code:
Dim prs As Presentation
For Each prs In Presentations
If ActivePresentation 'rest of code to check if filename contains "Analayze Data" Then
frmChecklist.Show
End If
Next prs
Thank you
Re: PowerPoint2010 - Open userform if file name contains
you can use instr to get a part name, like
Code:
if instr(filename, "Analyze Data") > 0 then ' filename match
' do stuff
end if
if "Analyze Data" words may be separated by some other words or even additional spaces, some changes would be needed
Re: PowerPoint2010 - Open userform if file name contains
Is filename a variable?
I have the below code and it's not opening the message box when it's searching for the filename. What am I missing?
Code:
Sub Auto_Open()
Dim FNames As String
Dim SearchFor As String
Dim prs As Presentation
'Open's UserForm if File labeled as "CBNA OT Risk and Control Update"
SearchFor = "CBNA OT Risk and Control"
For Each prs In Presentations
If InStr(FileName, SearchFor) > 0 Then
frmChecklist.Show
End If
Next prs
End Sub
Re: PowerPoint2010 - Open userform if file name contains
Quote:
Is filename a variable?
i just used filename as an example
look in the locals window to see the appropriate name for the filename of your prs object
it may be prs.filename or just prs.name, but as i do not have powerpoint i can not check
look in the view menu for the locals window, then drill down your object
Re: PowerPoint2010 - Open userform if file name contains
Hello,
The below code does what I need.
Code:
Dim SearchFor As String
Dim prs As Presentation
SearchFor = "CBNA OT Risk and Control"
For Each prs In Presentations
If InStr(prs.Name, SearchFor) > 0 Then
frmChecklist.Show
End If
Next prs
Thank you
Re: PowerPoint2010 - Open userform if file name contains