Open PowerPoint from Excel

  • Thread starter Thread starter smonczka
  • Start date Start date
S

smonczka

Can someone give me the VB code for opening up powerpoint from excel.
I am running a macro from excel that runs a macro in powerpoint. But
the macro errors out because it fails to open the presentation. If I
have PPT open and run the macro from Excel then everything works
corectly. I am using Office 2003 and XP. All files are in the same
directory as each other.

The code I am using ...

Sub PPTTest()
Dim PPT As Object

Set PPT = CreateObject("PowerPoint.Application")
PPT.Presentations.Open "C:\My Documents\Tracking\Presentation
template.ppt", , , False
PPT.Run "Presentation template.ppt!Module1.Import"

End Sub

Thanks for any help you can give me,
Steve
 
What does "the macro errors out because it fails to open the
presentation" mean? What error go you get? And, on what line in the
code?

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
Steve thanks for your artical. With some modifications I was able to
make the code open the ppt file. The only step I am missing is what is
the VB command in Powerpoint that runs a macro. In excel this would be
(application.run "name of macro"). This command dosn't seem to work in
PPT.

Thanks for your help.

And Tushar, thank you also for your responce. I will try to be more
explanitory in my questions in the future. I have only been posting
for a short time and have yet to pick up all the subtleties.

Steve
 
Hello smonczka,

If I might jump in to the conversation, here is a quick example that
works. The global variable 'sstring' allows you to send data to the
macro you call.


' in the powerpoint module

Global sstring

Sub msg()
MsgBox sstring
End Sub

' in the excel module
Global sstring
Dim PPApp As PowerPoint.Application
Dim PPPres1, PPPres2, PPPres3 As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide

Sub communicate()

Set PPApp = CreateObject("Powerpoint.Application")

Set PPPres1 = PPApp.Presentations.Open("ppt_comm.ppt")
PPApp.Visible = msoTrue

PPApp.Activate

PPPres1.sstring = "llel"
Call PPPres1.msg
End Sub

If you want more on communication, this link might
help. However, Shyam Pillai is showing ppt to ppt,not excel to ppt.

HTH,
Leef_me
Inter-presentation communication
http://skp.mvps.org/pptxp013.htm
 
Back
Top