Connect Excel to a powerpoint file in same folder

Tomcoll67

New Member
Joined
May 13, 2019
Messages
23
Team,
I am trying to connect an Excel Spreadsheet to a PowerPOint file in the same folder with a relative address.
It is not working. Can you please help?
Thank you,

( I copied from the Office Lab exactly, but it is not working)
The code is

Sub Refresh(ParamArray var() As Variant)

Dim pApp As Object
Dim pPreso As Object
Dim pSlide As Object
Dim sPreso As String



'Define path to Powerpoiunt Dashboard file path
sPreso = Dir(ActiveWorkbook.Path & ".\Dashboard-Disaster_Recovery_Yearbook_Metrics.pptm")

'Open and reference PowerPoint Dashboard file

On Error Resume Next
Set pApp = GetObject(class, "PowerPoint.Application")

If Err.Number <> 0 Then
Set pApp = CreateObject("PowerPoint.Application")
pApp.Visible = True
End If


On Error Resume Next
Set pPreso = pApp.Presentations(sPreso)

If Err.Number <> 0 Then
Set pPreso = pApp.Presentations.Open(Filename:=sPreso)
End If

'Update every chart (slide 1) in Param Array

Dim varSize As Integer
Dim i As Integer
Dim j As Integer
varSize = UBound(var) - LBound(var) + 1

For i = 0 To (varSize - 1)
pPreso.Slides(1).Shapes(var(i)).LinkFormat.Update
Next i

'For j = 0 To (varSize - 1)
'pPreso.Slides(2).Shapes(var(i)).LinkFormat.Update

End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi Tom,
I assume it's this line, and more specifically the dot at the start:
VBA Code:
'Currently:
sPreso = Dir(ActiveWorkbook.Path & ".\Dashboard-Disaster_Recovery_Yearbook_Metrics.pptm")
'Test first -> check the Direct window in the VBA editor:
Debug.Print ActiveWorkbook.Path & "\Dashboard-Disaster_Recovery_Yearbook_Metrics.pptm"
'Should be:
sPreso = Dir(ActiveWorkbook.Path & "\Dashboard-Disaster_Recovery_Yearbook_Metrics.pptm")
Cheers,
Koen
P.S. Next time put your code in the VBA tag that's in the post-editor on this forum, makes it much more readable.
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,840
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top