Question on using Form's Button in Excel

B

Bert

I use a button in Excel to call a file into Excel. Can I
use a button in excel to open up another Office
application such as Powerpoint?
 
J

jeff

Hi,
Yes, one way:

Private Sub CommandButton1_Click()
callppt
End Sub

Sub callppt()
x = Shell("C:\Program Files\Microsoft Office\Office10
\POWERPNT.EXE")
End Sub

jeff
 
B

Bert

Jeff,

Thanks so much, it worked. I have another question. Can a
powerpoint file be opened up thru this CommandButton in
excel (First open up powerpoint then open up the file I
need).

Thanks,

Bert
 
B

Bob Phillips

Sure it can

Set pptApp = CreateObject(,"Powerpoint.Application")
pptApp.V isible = True
pptApp.Presentations.Open FileName:="c:\My Documents\pres1.ppt"
 
S

Steve Garman

I think a stray comma and a stray space crept in there.

Dim pptApp As Object
Set pptApp = CreateObject("Powerpoint.Application")
pptApp.Visible = True
pptApp.Presentations.Open filename:="c:\My Documents\pres1.ppt"
 
B

Bert

When I try to run this I get a "Run-Time Error". Here's
the Code. Can you help me with this, Thanks:


Private Sub CommandButton1_Click()
callppt

End Sub

Sub callppt()
x = Shell("C:\Program Files\Microsoft
Office\Office\POWERPNT.EXE")

Dim pptApp As Object
Set pptApp = CreateObject("Powerpoint.Application")
pptApp.Visible = True
pptApp.Presentations.Open
Filename:="U\DATA\POWER\Learning.ppt"
 
S

Steve Garman

You don't need both the Shell and the CreateObject but I doubt that's
the source of the "Run-Time Error". It looks like you've split some of
the original lines.

Try the sub as below. Please note this is exactly 6 lines.

''''''''''''
Sub callppt()
Dim pptApp As Object
Set pptApp = CreateObject("Powerpoint.Application")
pptApp.Visible = True
pptApp.Presentations.Open Filename:="U\DATA\POWER\Learning.ppt"
End Sub
''''''''''''
 
B

Bert

I put in the 6 lines as you suggested and when I run it
comes back with error "Powerpoint could not open file"
 
Top