Results 1 to 6 of 6
  1. #1
    journeyman is offline Advanced Beginner
    Windows 11 Access 2016
    Join Date
    Dec 2022
    Posts
    85

    Access with powerpoint (Opening ppt not visible)

    Hi all,



    I am somewhat happy with Access ability to open and manipulate other MS applications - including PowerPoint.

    I am trying to open PowerPoint app, create a hidden presentation, add a slide, then display the whole PowerPoint presentation.

    Sounds easy... not so fast. I have tried various iteration of the following... finally resorting to ChatGPT (No answer given worked). So now, I finally come to an Access forum because I'm running this from Access.

    Code:
    Sub MakeInvisiblePresentationVisible()
    Dim pptApp As Object
    Dim pptPres As Object
    Dim slide As Object
    
    Set pptApp = CreateObject("PowerPoint.Application")
    Set pptPres = pptApp.Presentations.Add(msoFalse)  ' Add the presentation hidden
    Set slide = pptPres.Slides.Add(1, ppLayoutTitle)[
    slide.Shapes.Title.TextFrame.TextRange.Text = "Hello, World!"
    slide.Shapes.Placeholders(2).TextFrame.TextRange.Text = "This is a hidden presentation."
    
    pptApp.Visible = True ' Make sure the application is visible
    pptPres.Windows(1).Visible = True    ' Pure BS from ChatGPT - does not work 
    
    pptPres.Windows(1).WindowState = 1 ' Pure BS - errors out with [referring to Windows(1)]  1 is not in the range of 1 to 0....Just why?
    End Sub
    Thoughts appreciated

    Addendum:

    Shortly after posting this I discovered a method that does something unexpected.

    Code:
    pptPres.NewWindow
    I don't know exactly what it does, but it displays the hidden presentation window and seems to do what I need. so if anybody has thoughts about what's happening in either case, please feel free to contribute.

  2. #2
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    Automating PowerPoint from Access VBA is an entertaining thing to do, I've done quite a lot of it over the years and the inconsistency in the application of methods and properties is quite staggering.

    Have a look here http://skp.mvps.org/ppt00033.htm for a method to hide the slide being created.

    Good luck!
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    journeyman is offline Advanced Beginner
    Windows 11 Access 2016
    Join Date
    Dec 2022
    Posts
    85
    Thanks Minty.

    You're right. Powerpoint automation is relatively straightforward but it seems like PPT was developed somewhere else and hastily cobbled together with the MS logo.

    I any case, it works fine to create the slideshow directly from Access. I have my solutions, so, I can't complain.

    Thanks for your comments and tips.

    Cheers

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    Care to show the code then please?
    This site is here to help others, after all?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    journeyman is offline Advanced Beginner
    Windows 11 Access 2016
    Join Date
    Dec 2022
    Posts
    85
    The solution was included as an edit and addendum to my original post.

    If you dimension and set a PowerPoint presentation it will reside in memory, but not displayed on screen (insofar as I can understand).

    The presentation must be initialized to be displayed. This is why some solutions suggest saving and closing the presentation, then reopening it to see it. But reinitializing in that way is not required. You can simply display the presentation in a new window.

    e.g:

    Code:
    Set pptPres = pptApp.Presentations.Add(msoFalse)  ' Add the presentation hidden
    pptPres.NewWindow 'Present that presentation in a new window (initialise it)
    Note that if you set the presentation visible, it will already be initialized into the new window, but then you'll be stuck watching the presentation build.

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    Thank you.
    Always better to repost the code and pehaps highlight the changes, rather than hope someone goes back to the original post to see if anything has changed there and then notice if it had been chnaged?
    I myself would always come back to the last post where the site takes me.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Please reply to this thread with any new information or opinions.

Similar Threads

  1. make label visible on opening report
    By mainerain in forum Programming
    Replies: 4
    Last Post: 10-02-2020, 10:10 AM
  2. Access delivery from within Powerpoint?
    By vicsaccess in forum Access
    Replies: 1
    Last Post: 07-22-2016, 08:06 AM
  3. Access Form to Powerpoint
    By Thompyt in forum Import/Export Data
    Replies: 3
    Last Post: 12-19-2014, 08:03 PM
  4. Access Reports into Powerpoint
    By karthik in forum Reports
    Replies: 1
    Last Post: 11-28-2014, 11:36 AM
  5. Replies: 2
    Last Post: 01-06-2011, 04:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums