Tags: code, commandbutton, error, excel, microsoft, msdn, powerpoint, private, run-time, running, software

Running a CommandButton in Excel I get this error

On Microsoft » Microsoft Excel

8,817 words with 4 Comments; publish: Fri, 23 May 2008 07:41:00 GMT; (30647.12, « »)

When I try to open Powerpoint using a commandbutton I get

a "Run-Time Error". Here's

the Code. Can someone 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"

All Comments

Leave a comment...

  • 4 Comments
    • Is the code exactly as you show it, as we are getting wrap around.

      Try this alternative

      Private Sub CommandButton1_Click()

      callppt

      End Sub

      Sub callppt()

      Dim pptApp As Object

      Set pptApp = CreateObject("Powerpoint.Application")

      pptApp.Visible = True

      pptApp.Presentations.Open _

      Filename:="U\DATA\POWER\Learning.ppt"

      I have lost the shell command as it seems totally superfluous.

      HTH

      Bob Phillips

      ... looking out across Poole Harbour to the Purbecks

      (remove nothere from the email address if mailing direct)

      "Bert" <anonymous.excel.questionfor.info.discussions.microsoft.com> wrote in message

      news:8cf601c432b5$86179ba0$a301280a.excel.questionfor.info.phx.gbl...

      > When I try to open Powerpoint using a commandbutton I get

      > a "Run-Time Error". Here's

      > the Code. Can someone 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"

      >

      >

      #1; Fri, 23 May 2008 07:43:00 GMT
    • I put in the code as you suggested and I still get Run

      Time Error which says the "PowerPoint Can not open the

      File" Do you know why this is happening?

      >--Original Message--

      >Is the code exactly as you show it, as we are getting

      wrap around.

      >Try this alternative

      >Private Sub CommandButton1_Click()

      >callppt

      >End Sub

      >Sub callppt()

      >Dim pptApp As Object

      >Set pptApp = CreateObject("Powerpoint.Application")

      >pptApp.Visible = True

      >pptApp.Presentations.Open _

      >Filename:="U\DATA\POWER\Learning.ppt"

      >I have lost the shell command as it seems totally

      superfluous.

      >

      >--

      >HTH

      >Bob Phillips

      > ... looking out across Poole Harbour to the Purbecks

      >(remove nothere from the email address if mailing direct)

      >"Bert" <anonymous.excel.questionfor.info.discussions.microsoft.com> wrote in

      message

      >news:8cf601c432b5$86179ba0$a301280a.excel.questionfor.info.phx.gbl...

      >> When I try to open Powerpoint using a commandbutton I

      get

      >> a "Run-Time Error". Here's

      >> the Code. Can someone 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"

      >>

      >>

      >

      >.

      >

      #2; Fri, 23 May 2008 07:44:00 GMT
    • Well that presumably means that the file does not exist.

      When I tried it with a file that did exits, it worked fine.

      --

      HTH

      Bob Phillips

      ... looking out across Poole Harbour to the Purbecks

      (remove nothere from the email address if mailing direct)

      "Bert" <anonymous.excel.questionfor.info.discussions.microsoft.com> wrote in message

      news:8c6401c432c5$34c55430$a601280a.excel.questionfor.info.phx.gbl...

      > I put in the code as you suggested and I still get Run

      > Time Error which says the "PowerPoint Can not open the

      > File" Do you know why this is happening?

      >

      > >--Original Message--

      > >Is the code exactly as you show it, as we are getting

      > wrap around.

      > >

      > >Try this alternative

      > >

      > >Private Sub CommandButton1_Click()

      > >callppt

      > >

      > >End Sub

      > >

      > >Sub callppt()

      > >Dim pptApp As Object

      > >Set pptApp = CreateObject("Powerpoint.Application")

      > >pptApp.Visible = True

      > >pptApp.Presentations.Open _

      > >Filename:="U\DATA\POWER\Learning.ppt"

      > >

      > >I have lost the shell command as it seems totally

      > superfluous.

      > >

      > >

      > >

      > >--

      > >

      > >HTH

      > >

      > >Bob Phillips

      > > ... looking out across Poole Harbour to the Purbecks

      > >(remove nothere from the email address if mailing direct)

      > >

      > >"Bert" <anonymous.excel.questionfor.info.discussions.microsoft.com> wrote in

      > message

      > >news:8cf601c432b5$86179ba0$a301280a.excel.questionfor.info.phx.gbl...

      > >> When I try to open Powerpoint using a commandbutton I

      > get

      > >> a "Run-Time Error". Here's

      > >> the Code. Can someone 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"

      > >>

      > >>

      > >>

      > >>

      > >

      > >

      > >.

      > >

      #3; Fri, 23 May 2008 07:45:00 GMT
    • Thanks,

      I got it to work!!!

      >--Original Message--

      >Well that presumably means that the file does not exist.

      >When I tried it with a file that did exits, it worked

      fine.

      >--

      >HTH

      >Bob Phillips

      > ... looking out across Poole Harbour to the Purbecks

      >(remove nothere from the email address if mailing direct)

      >"Bert" <anonymous.excel.questionfor.info.discussions.microsoft.com> wrote in

      message

      >news:8c6401c432c5$34c55430$a601280a.excel.questionfor.info.phx.gbl...

      >> I put in the code as you suggested and I still get Run

      >> Time Error which says the "PowerPoint Can not open the

      >> File" Do you know why this is happening?

      >>

      >> >--Original Message--

      >> >Is the code exactly as you show it, as we are getting

      >> wrap around.

      >> >

      >> >Try this alternative

      >> >

      >> >Private Sub CommandButton1_Click()

      >> >callppt

      >> >

      >> >End Sub

      >> >

      >> >Sub callppt()

      >> >Dim pptApp As Object

      >> >Set pptApp = CreateObject("Powerpoint.Application")

      >> >pptApp.Visible = True

      >> >pptApp.Presentations.Open _

      >> >Filename:="U\DATA\POWER\Learning.ppt"

      >> >

      >> >I have lost the shell command as it seems totally

      >> superfluous.

      >> >

      >> >

      >> >

      >> >--

      >> >

      >> >HTH

      >> >

      >> >Bob Phillips

      >> > ... looking out across Poole Harbour to the

      Purbecks

      >> >(remove nothere from the email address if mailing

      direct)

      >> >

      >> >"Bert" <anonymous.excel.questionfor.info.discussions.microsoft.com> wrote in

      >> message

      >> >news:8cf601c432b5$86179ba0$a301280a.excel.questionfor.info.phx.gbl...

      >> >> When I try to open Powerpoint using a commandbutton I

      >> get

      >> >> a "Run-Time Error". Here's

      >> >> the Code. Can someone 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"

      >> >>

      >> >>

      >> >>

      >> >>

      >> >

      >> >

      >> >.

      >> >

      >

      >.

      >

      #4; Fri, 23 May 2008 07:46:00 GMT