none
How to detect the excel is call by powerpoint? RRS feed

  • Question

  • Hi,

    I have a VSTO add-in which will prompt user to input file setting (frm.ShowDialog()) when open or save file.  It normally work fine but I got a problem that when user add excel object into PowerPoint silde by ("Insert" -> "Object" -> Select from file -> select excel), the PowerPoint hang caused by waiting the answer of excel prompt but it does not load on screen.

    So how can I detect the add-in is called by others application?  If I can know the excel is called by PowerPoint, then I can skip the setting prompt and let it run normally.

    Thanks.


    calendarw

    Wednesday, January 22, 2014 7:30 AM

All replies

  • Hello calendarw,

    It looks like you are interested in the UserControl property of the Application class from the Excel Object Model. It returns true if the application is visible or if it was created or started by the user. Or false if you created or started the application programmatically by using the CreateObject or GetObject functions, and the application is hidden.

    • Marked as answer by calendarw Thursday, January 23, 2014 12:33 AM
    • Unmarked as answer by calendarw Thursday, February 20, 2014 8:48 AM
    Wednesday, January 22, 2014 8:00 PM
  • Hi,

    I got a problem that if the an excel is opened before user add another excel into PowerPoint, then the UserControl is True too in event.

    So may I have any other method to determine does the event called by PowerPoint or user?

    Thanks.


    calendarw

    Thursday, February 20, 2014 8:43 AM
  • Hello calendar,

    Did you try to check out the process name?

    Please check out the following similar forum threads for more information:

    How to stop an addin loading if PowerPoint/Excel/Word is being automated or embedded

    Determine, via VSTO, if document has been opened in OLE Viewer

    Friday, February 21, 2014 8:52 PM
  • Hi,

    I was tested that if it's opened by user before insert excel object to PowerPoint, the process name is explorer, so I want to check any alternative for solving this problem


    calendarw

    Sunday, February 23, 2014 12:09 PM
  • It looks like you didn't open the links I provided in my previous message.

    Did you try to use the CommandBars.GetVisibleMso("string value that's the idMso of the Ribbon control") method to check whether a particular control is visible at the moment?

    There is a chance that some controls are not shown when the host application is run programmatically (embedded).

    Sunday, February 23, 2014 4:54 PM
  • Hi,

    Due to the Control is added programmatically by CommandBar.Controls.Add(1), so I haven't the idMso.

    But I tested that if I get the control by FindControl in CommandBars, the Visible is True.  I have compared the instance id is same with my object, so the Visible is True too.


    calendarw


    • Edited by calendarw Wednesday, February 26, 2014 7:34 AM typo
    Wednesday, February 26, 2014 6:40 AM
  • You don't need to use your own controls.

    You can try to find controls that are shown if you run Excel as a standalone application and are hidden if Excel is embedded in another application.

    Wednesday, February 26, 2014 11:25 AM
  • Hi,

    I tested that if I started excel before I insert excel object into PowerPoint, the value is True when calling CommandBars.GetVisibleMso in App_WorkbookOpen event, and the PowerPoint is unable to save unless I exit the excel.


    calendarw


    • Edited by calendarw Thursday, February 27, 2014 6:53 AM
    Thursday, February 27, 2014 6:51 AM
  • Hi,

    I was tested that if it's opened by user before insert excel object to PowerPoint, the process name is explorer, so I want to check any alternative for solving this problem


    calendarw

    I'm on the same problem. Did you find a solution?

    I'm using the same toolbar for word,excel,powerpoint and i cant figure it out what Eugene said about CommandBars.GetVisibleMso.

    Thanks in advance

    Monday, May 5, 2014 5:39 AM
  • You don't need to use your own controls.

    You can try to find controls that are shown if you run Excel as a standalone application and are hidden if Excel is embedded in another application.

    Could you give us an example?

    Im stucked, because if someone opens excel before in Word i  insert a table from Excel SpreedSheet, Im not able to know if its runing embedded or not!

    I'm getting mad with this bug!

    Thank you in advance.

    Monday, May 5, 2014 5:43 AM
  • Hi,

    I was tested that if it's opened by user before insert excel object to PowerPoint, the process name is explorer, so I want to check any alternative for solving this problem


    calendarw

    I'm on the same problem. Did you find a solution?

    I'm using the same toolbar for word,excel,powerpoint and i cant figure it out what Eugene said about CommandBars.GetVisibleMso.

    Thanks in advance

    Hi, I still unable to found any solution.

    I have tested not to prompt my dialog if PowerPoint is started by checking process in excel but still causing unable to save PowerPoint and Excel hang when exit.


    calendarw

    Wednesday, May 28, 2014 11:19 AM