View Single Post
 
Old 06-08-2016, 05:04 AM
Nick70 Nick70 is offline Windows 10 Office 2010 64bit
Novice
 
Join Date: Jun 2016
Location: London
Posts: 13
Nick70 is on a distinguished road
Default Open file which contains specific words in title

Hi,

I have some code which opens a file called "Presentation.pptx" then copies its slides onto an active ppt file.

Code:
Sub main()
Dim objPresentation As Presentation
Dim i As Integer

'open the target presentation
Set objPresentation = Presentations.Open("C:\Presentation.pptx")
For i = 1 To objPresentation.Slides.Count
    objPresentation.Slides.Item(i).Copy
    Presentations.Item(1).Slides.Paste
Next i
objPresentation.Close
End Sub
Is it possible to amend code so that the file which is opened is the one which "contains" the word "Presentation" in its title as opposed to be called Presentation.pptx?
For example file could be called PresentationB.pptx and still be opened.

Reason for this is that file name changes every week (but always contains word Presentation) so if we put in macro a fixed file name the macro may not be able to find it.

Thanks,
Nic
Reply With Quote