+ Reply to Thread
Results 1 to 7 of 7

Combination question for excel and powerpoint macros

  1. #1
    Registered User
    Join Date
    04-23-2014
    Location
    Norge
    MS-Off Ver
    Excel 2010
    Posts
    21

    Combination question for excel and powerpoint macros

    Hi,

    I have an excel sheet with macros that will open a powerpoint presentation at a specific slide and show it as a slide show. After an animation is run in powerpoint I want to return to excel. I presently accomplish this with a macro in powerpoint which simply closes powerpoint. This is not very elegant for two reasons:

    1. I use a CommandButton in powerpoint to launch the Application.Quit macro. This button is visible throughout the presentation, which is distracting/confusing. Ideally the button will only appear after the animation has completed.
    2. The Application.Quit macro then returns the excel sheet to the monitor. It would be better if I could decide which excel sheet to show, as the desired sheet may not be the one that was last visible.

    Does anyone have any thoughts on improvements in the solution, and hopefully also some working code? I am using Office 2007 and 2010.

    BTW I have experimented with having only one macro, in excel that will start the powerpoint presentation, then wait for a while, then close powerpoint and go to the desired excel sheet. The disadvantage of this solution is that I want a manual trigger of the closing of the powerpoint presentation, as the user should be able to study whatever is on the screen at his/her own pace, before closing the presentation and reverting to excel. Would it be possible to have a message box appear in the powerpoint presentation, triggered by the excel macro, which would continue the macro (i.e. closing powerpoint and returning to excel) when the user responds?

    Appreciate all help, hints and comments
    Christopher

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Combination question for excel and powerpoint macros

    Hi Christopher,

    Please forgive my PowerPoint VBA programming errors, since this is my first attempt at PowerPoint VBA. I had two main techincal challenges:
    a. Learning the basics of PowerPoint VBA.
    b. Identifying when the User relinquished MANUAL control of PowerPoint (solved by a 'Slide Show End' Class Event).

    Attached are two files (written and tested using Office 2003) both containing VBA code:
    a. Excel File
    b. PowerPoint File (with 4 slides)

    The following references were extremely useful:
    1. PowerPoint Event Handler Demo pptEvent.ppt (the only file in pptEvent.zip). Thank you - great code [PPT web site]:
    http://www.pptfaq.com/FAQ00004_Make_..._to_events.htm

    2. PowerPoint mouse and cursor routines - Thank you Todd Main:
    http://stackoverflow.com/questions/2...powerpoint-vba

    Command Buttons on the LAST PowerPoint slide. I put 3 (Return to Excel) 'CommandButtons' on the last slide, which are all SUPPOSED to function identically when 'Clicked.'
    a. Ordinary Shape
    b. Static Active X. I have had intermittent problems with this CommandButton. It seems to be especially problemsome when switching between versions of Office (especially downwad from 2007 [or higher] to 2003). It was operational at the time of this writing.
    c. Dynamic Active X (created at runtime).

    To implement the CommandButtons, each had to have a UNIQUE name. I also had to NAME the Slide that holds the CommandButtons.
    There are PowerPoint VBA macros included to help you do both of these tasks. I don't think the CommandButton(s) are needed, since Excel has the ability to close the PowerPoint Application when MANUAL control of the Slide Show ends.


    There are 4 ways I know of for the User to Exit from the PowerPoint Automation. The User:
    a. Presses the 'Esc' key DURING the slide show (Runtime Error -2147188160 in PowerPoint 2003). or
    b. Clicks on the 'Exit' Shape on the 'Last Slide'. or
    c. Presses the 'Esc' key after the slide show is done. or
    d. Attempts to access the 2nd slide after the last slide (i.e. slide after the 'Black Screen').


    The flow of control of the Excel/PowerPoint Macros is as follows:
    a. Excel Macro starts.
    b. Excel Macro calls PowerPoint Macro.
    c. PowerPoint Macro runs the slide Show. Several seconds after the last slide appears, the last slide 'CommandButton' is made visible.
    The PowerPoint Macro finishes (returning Macro control to the original Excel Macros) and the User now has MANUAL control of the PowerPoint Slide Show.
    d. The Excel Macro calls a second PowerPoint Macro. The second PowerPoint Macro obtains the 'Slide Show Status' (either COMPLETED or still under User Manual Control). The second PowerPoint Macro returns the Status to the Excel Macro and the second Excel PowerPoint Macro terminates. This step is repeated (i.e. the Excel Macro periodicially calls the PowerPoint second Macro) until the PowerPoint 'Slide Show Status' is COMPLETED.
    e. The Excel Macro then closes the PowerPoint Presentation (file), and closes the PowerPoint Application.

    I left PowerPoint VBA debugging statements activated so you could see the sequence of events in PowerPoint VBA.


    I have experimented with having only one macro, in excel that will start the powerpoint presentation, then wait for a while, then close powerpoint and go to the desired excel sheet
    VBA runs serially, and not in parallel when the applications are connected. This is important for two reasons:
    a. The Excel VBA Master Macro calls the PowerPoint VBA (application.run) subordinate Macro. The Excel VBA waits for the PowerPoint VBA to finish before the Excel VBA continues. This is useful because Excel can obtain status information from PowerPoint when
    the PowerPoint macro completes (using a function return value).
    b. Because VBA threads run in parallel, if the thread is broken, the entire VBA terminates. Excel VBA Master Macro calls the PowerPoint VBA (application.run) subordinate Macro and the PowerPoint Macro stops for any reason (usually closing the PowerPoint file or closing the powerpoint application or a PowerPoint VBA runtime error) all VBA activity stops (including VBA activity in the Excel file).

    Lewis
    Attached Files Attached Files
    Last edited by LJMetzger; 08-19-2014 at 02:37 PM. Reason: Added Attachments

  3. #3
    Registered User
    Join Date
    04-23-2014
    Location
    Norge
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Combination question for excel and powerpoint macros

    Wow, sounds great! Can't wait to try this Probably will not be for a few days though, busy with boring office stuff...

  4. #4
    Registered User
    Join Date
    04-23-2014
    Location
    Norge
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Combination question for excel and powerpoint macros

    Dear Lewis, very impressive solution, far above my level of understanding, but I am looking, testing and learning! The two issues I am experimenting with is:

    1. getting the excel macro to open a specific (but changing) numbered slide, depending on a variable value in excel
    2. getting the correct power point macro to return to a specific excel sheet, depending on which slide was shown in powerpoint (only one slide is to be shown per instance of running the macros). I guess that means a different macro for each button, which is OK, there will only be about 30-40 slides.

    I have cracked the code of how to run a specific slide number from my excel macro, just have to implement it within your huge and complext set up, but so far not certain how to return from excel to to a named powerpoint sheet...

    Chris

  5. #5
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Combination question for excel and powerpoint macros

    Hi Chris,

    1. getting the excel macro to open a specific (but changing) numbered slide, depending on a variable value in excel
    2. getting the correct power point macro to return to a specific excel sheet, depending on which slide was shown in powerpoint (only one slide is to be shown per instance of running the macros).
    I'm working on both of these problems, but it will take several days. Excel/Powerpoint dual debugging can be tedious, frustrating, and rewarding at the same time.

    I'm working on starting the slide show from a list of slide numbers and/or names on the Excel side. There can be many lists of slide numbers/names (and the items on the list can be in any order and can be repeated).

    In the mean time the following POWERPOINT macro may help you obtain a slide number from a name. To the best of my knowledge, PowerPoint can't directly access a slide by name, only by number. The following macro translates a name into a slide number (and returns 0 (ZERO) if the name doesn't exist.
    Please Login or Register  to view this content.
    Lewis

  6. #6
    Registered User
    Join Date
    04-23-2014
    Location
    Norge
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Combination question for excel and powerpoint macros

    Lewis, the following simple code works for opening the slide number I want:

    Sub ShowPhaseVideo()
    '

    Please Login or Register  to view this content.
    I just need to copy the relevant parts of this code into your macro. I did have some problems when I tried, but haven't really had the time to test it thoroughly.... Thanks for all your help so far, looking forward to seeing if you come up with some solution for opening/returning to a specific Excel worksheet when the appropriate button is pressed on the excel slide.

  7. #7
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Combination question for excel and powerpoint macros

    Hi Christopher,

    Thanks for posting your code. I'm still working on the update to my previous post. If I don't have any major problems or unforseen demands on my time, I should be finished in a week or two.

    Lewis

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 13
    Last Post: 01-11-2013, 04:46 PM
  2. Run a Powerpoint Macros from Excel
    By undergraduate in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2010, 06:50 PM
  3. Developing a Combination of Columns within Excel, using Macros
    By btmeyer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2008, 11:17 PM
  4. Excel to powerpoint and back macros
    By scanavan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-21-2007, 01:27 PM
  5. Excel macros to PowerPoint problem
    By tyler3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-13-2006, 04:44 PM

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