+ Reply to Thread
Results 1 to 5 of 5

Open Powerpoint From Excel

Hybrid View

  1. #1
    Registered User
    Join Date
    06-02-2008
    Posts
    10

    Open Powerpoint From Excel

    I am trying to open a Powerpoint template from Excel using late binding. The following code works, however I would like to minimize or hide the Powerpoint application while the presentation is being populated with Excel data.
    Have tried removing Line 7, but thencode fails at line 8.

    Any help much appreciated.

    Code:

    Line 1: Dim ppApp As Object
    Line 2: Dim ppPres As Object
    Line 3: Dim ppSlide As Object
    Line 4: Dim ppShape As Object
    Line 5: Dim ppSlideNum As Integer

    Line 6: Set ppApp = CreateObject("Powerpoint.Application")
    Line 7: ppApp.Visible = True
    Line 8: Set ppPres = ppApp.presentations.Open(Environ("userprofile") & "\ROI Advantage\Presentation Template.pot")
    Line10: Set ppSlide = ppPres.Slides

    '-----------------------------------------------------------------------------
    'This selects slide 1 and copies the 'subject' and 'customer' data to the slide
    '-----------------------------------------------------------------------------
    Line 11: ppSlideNum = 1

    Line 12: ppSlide(ppSlideNum).Select

    Line 13: Set ppShape = ppPres.Slides(ppSlideNum).Shapes("txtSubject")
    Line 14: ppShape.TextFrame.TextRange.Characters(Start:=1, Length:=0).Select
    Line15: ppShape.TextFrame.TextRange.Text = ""
    Line 16: ppShape.TextFrame.TextRange.Characters(Start:=1, Length:=0).Text = Sheet1.Range("Subject").Text

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Please read the Forum Rules and then wrap your code with Code Tags.

  3. #3
    Registered User
    Join Date
    06-02-2008
    Posts
    10

    Thumbs up Open Powerpoint Presentation from Excel

    I am trying to open a Powerpoint template from Excel using late binding. The following code works, however I would like to minimize or hide the Powerpoint application while the presentation is being populated with Excel data.
    Have tried removing 'ppApp.Visible=true' but then code fails at next line.

    Any help much appreciated.

    Dim ppApp As Object
    Dim ppPres As Object
    Dim ppSlide As Object
    Dim ppShape As Object
    Dim ppSlideNum As Integer
    
    Set ppApp = CreateObject("Powerpoint.Application")
      ppApp.Visible = True
    Set ppPres = ppApp.presentations.Open(Environ("userprofile") & "\ROI Advantage\Presentation Template.pot")
    Set ppSlide = ppPres.Slides
    
    '-----------------------------------------------------------------------------
    'This selects slide 1 and copies the 'subject' and 'customer' data to the slide
    '-----------------------------------------------------------------------------
     ppSlideNum = 1
     ppSlide(ppSlideNum).Select
    
    Set ppShape = ppPres.Slides(ppSlideNum).Shapes("txtSubject")
     ppShape.TextFrame.TextRange.Characters(Start:=1, Length:=0).Select
     ppShape.TextFrame.TextRange.Text = ""
     ppShape.TextFrame.TextRange.Characters(Start:=1, Length:=0).Text = Sheet1.Range("Subject").Text

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    You can not automate ppt while the application is invisible.

    If your really do not want to see it then try positioning it of the screen. One potential problem is if your code fails the application could be left off screen so make sure you have error handling in your code.
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    06-02-2008
    Posts
    10

    Problem Resolved

    Andy, thanks for confirming that Powerpoint cannot be opened invisibly. After further trial and error, I have stumbled on an acceptable solution by immediately minimizing the PP application with code as below.

    Cheers

    PeterT

    Set ppApp = CreateObject("Powerpoint.Application")
        ppApp.Visible = True
        ppApp.WindowState = 2

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1