none
running an excel macro from powerpoint RRS feed

  • Question

  • i have a PowerPoint that has buttons that need to run excel macros without having to open excel each time i have code that works but requires excel to be opened and closed every time as follows: 



    Sub Run_Excel_Macro_From_PPT()
    Dim oXL As Excel.Application            ' Excel Application Object
    Dim oWB As Excel.Workbook               ' Excel Workbook Object
    Dim sPName As String                    ' Variable - Active Presentation Name

    On Error GoTo Err_PPXL


    Set oXL = New Excel.Application
    Set oWB = oXL.Workbooks.open("G:\Documents\psi development\old developemt files\120420_DMX Controller rev4.xlsm")

    ' Set Excel as Visibile - Turn Off if not needed
    oXL.Visible = True

    ' Pass and Argument
    sPName = ActivePresentation.Name

    ' Run the Macro without Argument
    oXL.Application.Run "'PSI100'"

    ' Save and Close the Workbook
    oWB.Save
    oWB.Close (False)


    ' Quit the Excel
     oXL.Quit


    ' Release Objects - Good Practive
    If Not oWB Is Nothing Then Set oWB = Nothing
    If Not oXL Is Nothing Then Set oXL = Nothing


    Err_PPXL:
    If Err <> 0 Then
        MsgBox Err.Description
        Err.Clear
    End If

    End Sub

     
    Monday, April 23, 2012 6:49 AM

Answers

All replies

  • Hi ianlynk,

    Thanks for posting in the MSDN Forum.

    Would you please clarify your goal? Do you want to handle exel issue without Excel Object Moduel? It seems impossible if it is.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, April 24, 2012 2:54 AM
    Moderator
  • no i am running excel in the background to handle the math the PowerPoint acts as a user interface with controls to run macro code in excel and return an external action to a com port.    
    Tuesday, April 24, 2012 3:29 AM
  • Hi,

    I'm afraid people need to run macro visually, in other words, macros could not run without Excel Open.  Think about running macro in background, it could raise potential security concern.

    Another attempt to similar scenario: http://forums.asp.net/t/1454168.aspx

    best regards,


    Forrest Guo | MSDN Community Support | Feedback to manager

    • Marked as answer by Forrest GuoModerator Thursday, April 26, 2012 1:26 AM
    • Unmarked as answer by ianlynk Friday, April 27, 2012 8:27 AM
    Tuesday, April 24, 2012 9:27 AM
    Moderator
  • no i need excel open but i don't want the user getting to the sheets or code excel is used for the math display is done in PowerPoint i pass instructions from PowerPoint to excel then they are passed back to the user by a light going on or a change in the slide some times both. 
    Friday, April 27, 2012 8:26 AM
  • Hi,

    Your question falls into the paid support category which requires a more in-depth level of support. Please visit the below link to see the various paid support options that are available to better meet your needs.

    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    best regards,



    Forrest Guo | MSDN Community Support | Feedback to manager

    • Marked as answer by ianlynk Thursday, May 10, 2012 9:30 AM
    Wednesday, May 2, 2012 8:30 AM
    Moderator