user1204121
user1204121

Reputation: 385

VBA run-time error when opening PowerPoint from Excel

I am currently experiencing a strange error. We have developed a tool that is used by many people and ONE of them has problems after he got a new computer. The macro opens a PPT file located on the network (the user has access to the presentation - I tested this).

Here is the code:

Dim ppapp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim MyPath
MyPath = Workbooks("MyTool.xls").Sheets("Update").Range("start")

Set ppapp = New PowerPoint.Application
ppapp.WindowState = ppWindowMinimized
ppapp.Visible = True
Set PPPres = ppapp.Presentations.Open(MyPath, msoTrue, msoTrue)

The macro fails at this line:

Set PPPres = ppapp.Presentations.Open(MyPath, msoTrue, msoTrue)

Run-time error -2147467259 (80004005): PowerPoint could not open the file The strange thing is that it works for all users except one. The platform is Win7 and Excel 2010.

Any help is much appreciated!

Upvotes: 1

Views: 1657

Answers (1)

Phil
Phil

Reputation: 11

Disclaimer on my answer with a limited knowledge of programming and VBA. My only experience is through excel and word.

Is it a problem with the office excel reference library is it? It may be better to make the code late bind rather than early bind if you've got the program go to different systems.

Dim the Powerpoint application and presentation as objects and change references to their numerical values.

Dim ppapp As Object
Dim PPPres As Object
Dim MyPath
MyPath = Workbooks("MyTool.xls").Sheets("Update").Range("start")

Set ppapp = New PowerPoint.Application
ppapp.WindowState = 2 'this would have to be changed to the numerical code; ppWindowMinimized = 2
ppapp.Visible = True
Set PPPres = ppapp.Presentations.Open(MyPath, -1, -1) 'these would also may have to be changed, not sure though - -1 = msoTrue.

Upvotes: 1

Related Questions