PDA

View Full Version : VBA to change PowerPoint link sources to the Excel file that opened it



gcservi
07-11-2012, 04:14 PM
Hey, all. I have an Excel template users open and enter client data. A macro button saves the file to their desktop with a new client file name and opens a PowerPoint template. I have links in the PowerPoint whose source I would like to automatically update with the path and file name of the Excel file that opened it i.e. its not a fixed path and user could have more than one Exccel file opened. I have the Excel file's path and file name stored in a cell. Any help? Thanks.

John Wilson
07-11-2012, 11:21 PM
You would need to explain / post the code you have.

This might get you started:

Sub link_switch()
Dim osld As Slide
Dim oHL As Hyperlink
Dim strNewLink As String
'strNewLink= set to the [path and name in the Excel file]
For Each osld In ActivePresentation.Slides
For Each oHL In osld.Hyperlinks
oHL.Address = strNewLink
Next oHL
Next osld
End Sub