Results 1 to 8 of 8

Thread: Power point already open

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2004
    Posts
    60

    Power point already open

    I have the following code which opens PowerPoint, creates a presentation, adds a slide and then inserts an image onto the slide:

    VB Code:
    1. Private Sub openPowerPoint()
    2.     Dim ppObject As PowerPoint.Application
    3.     Dim ppPres As PowerPoint.Presentation
    4.     Dim picLocation As String
    5.    
    6.     'Open and show PowerPoint
    7.     Set ppObject = New PowerPoint.Application
    8.     ppObject.Visible = True
    9.    
    10.     'Add presentation to PowerPoint
    11.     ppObject.Presentations.Add
    12.     Set ppPres = ppObject.Presentations.Item(1)
    13.    
    14.     'Add a blank slide to PowerPoint presentation
    15.     ppPres.Slides.Add 1, ppLayoutBlank
    16.     ppPres.Slides(1).Select
    17.    
    18.     'Insert picture
    19.     picLocation = txtToInsert.Text
    20.     'size needs to be decided
    21.     ppPres.Slides(1).Shapes.AddPicture(FileName:=picLocation, LinkToFile:=False, SaveWithDocument:=True, Left:=0, Top:=0, Width:=170, Height:=230).Select
    22.  
    23. End Sub

    Can anybody help me to perform a similar task but with powerpoint already open?
    The code would just have to create a new slide and then insert the image.

    Thanks

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Power point already open

    i would believe that if power point is already open the only change you would have to make is
    Set ppObject = New PowerPoint.Application
    leave out

    rgds pete

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Power point already open

    Take out the ppObject.Presentations.Add line?


    Has someone helped you? Then you can Rate their helpful post.

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Power point already open

    Quote Originally Posted by westconn1
    i would believe that if power point is already open the only change you would have to make is


    leave out

    rgds pete
    Can't do that... You'll get an "Object variable or With block variable not set" error...


    Has someone helped you? Then you can Rate their helpful post.

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Power point already open

    change if from "new"?

    Set ppObject = PowerPoint.Application

    or does it even matter if it is already open?
    p.

  6. #6
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Power point already open

    Quote Originally Posted by westconn1
    change if from "new"?

    Set ppObject = PowerPoint.Application

    or does it even matter if it is already open?
    p.
    Then you get an "ActiveX component can't create object" error


    Has someone helped you? Then you can Rate their helpful post.

  7. #7

    Thread Starter
    Member
    Join Date
    Sep 2004
    Posts
    60

    Re: Power point already open[RESOLVED]

    cheers for that, worked by removing the line

    VB Code:
    1. ppObject.Presentations.Add

    Thanks

  8. #8
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Power point already open[RESOLVED]

    Quote Originally Posted by wallacej
    cheers for that, worked by removing the line

    VB Code:
    1. ppObject.Presentations.Add

    Thanks
    You're welcome. Just to point out that if PowerPoint isn't open though, it will cause an error


    Has someone helped you? Then you can Rate their helpful post.

Posting Permissions

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



Click Here to Expand Forum to Full Width