Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Opening ppt

Hi,

Should be a fairly simple one this but my head's in the clouds today and you guys will do this a lot quicker than I could hope to...

I am running a piece of code in Excel to open and transfer to a ppt. First thing I need to do is check if there is a presentation open, if not then look for C:\MyFolder\MyPres.ppt

If this doesn't exist then to open
C:\MainFolder\Pres.ppt    which will always exist.

Kind regards
Darren
0
UINVDJM
Asked:
UINVDJM
  • 2
  • 2
1 Solution
 
mvidasCommented:
Hey Darren, long time,

Give this a shot:

Sub ForDarren()
 Dim HasPresentation As Boolean, PPTApp As Object
 On Error Resume Next
 Set PPTApp = GetObject(, "powerpoint.application")
 On Error GoTo 0
 If PPTApp Is Nothing Then
  Set PPTApp = CreateObject("powerpoint.application")
  PPTApp.Visible = True
  HasPresentation = False
 Else
  If PPTApp.ActivePresentation Is Nothing Then
   HasPresentation = False
  Else
   HasPresentation = True
  End If
 End If
 If Not HasPresentation Then
  If Len(Dir("C:\MyFolder\MyPres.ppt")) = 0 Then
   PPTApp.Presentations.Open "C:\MainFolder\Pres.ppt"
  Else
   PPTApp.Presentations.Open "C:\MyFolder\MyPres.ppt"
  End If
 End If
End Sub

Matt
0
 
UINVDJMAuthor Commented:
Long time indeed, figured is what about time I returned and hounded you guys some more! ;)

Your code works perfectly of course. Thank you kindly!
0
 
mvidasCommented:
Glad to help! First time I've ever written anything powerpoint related :)
0
 
UINVDJMAuthor Commented:
I've just picked it up recently and now trying to tidy up a lot of reports that I had written in Excel. It seems fairly intuitive.

I may have a more complex question in the next couple of days so keep your eyes open! :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now