PDA

View Full Version : [SOLVED:] Address PowerPoint when its name constantly changes



o0omax
08-01-2022, 10:17 AM
Hello,

I want to copy a Diagram from Excel to a specific Powerpoint. Currently I am addressing this Powerpoint with its Name (MyPowerpoint.pptx). I searched for a way to find this PowerPoint (it will be in the same folder as the excel) but without mentioning its name.

I searched the internet and read things about CustomDocumentProperties or Tags but could not figure it out.

How can I copy something from excel to powerpoint, without mentioning the Name of the Powerpoint?

Kind regards

John Wilson
08-01-2022, 12:36 PM
You probably need to explain WHY the name is constantly changing. Will it be the only pptx in the same folder as the excel file?

o0omax
08-01-2022, 12:51 PM
It might not constantly change, but the user could write v1 oder v2 at the end of the file.

Yes it is planned, that is the only Powerpoint in this folder. Have to write it into the excel and highlight it because otherwise people will put files in there..

John Wilson
08-01-2022, 01:30 PM
This is,a general "Open the only pptx in a folder" routine that should give you a start.


Sub noName_open()
' change this folder path obviously!
Const sFolderPath As String = "c:\users\info\Desktop\test\"
Const sFilespec As String = "*.pptx"
Dim strPresPath As String
Dim opres As Presentation
strPresPath = Dir$(sFolderPath & sFilespec)
Set opres = Presentations.Open(sFolderPath & strPresPath)
End Sub

o0omax
08-01-2022, 01:43 PM
Thanks will try it out right now!

Paul_Hossler
08-01-2022, 08:37 PM
I thought you were looking for an Excel macro that would open the PP file



Option Explicit


Sub OpenTheOnlyOne()
Dim sPPTX As String
Dim oPres As Object, oPP As Object


sPPTX = Dir(ThisWorkbook.Path & Application.PathSeparator & "*.pptx")
sPPTX = ThisWorkbook.Path & Application.PathSeparator & sPPTX

Set oPP = CreateObject("Powerpoint.Application")
Set oPres = oPP.presentations.Open(sPPTX)
End Sub

o0omax
08-11-2022, 01:48 AM
solved