When embedding worksheet in powerpoint presentation

Add-in Express™ Support Service
That's what is more important than anything else

When embedding worksheet in powerpoint presentation
 
Stuart Kolodner




Posts: 35
Joined: 2009-10-09
I'm having problems with document embedded in other documents. I have an Excel spreadsheet embedded inside a powerpoint presentation (using Office 2010). Our add-in runs in both those office applications. For the instance of Excel started for the embedded spreadsheet, there are lots of fields in the Excel Application object that are null. For example, the member "ActiveCell" returns null in the embedded instance.

This appears to be a new source of bugs for me as I must not have tried this sceario before. I know this is probably not an add-in-express issue, but I'm hoping someone can provide some guidance. I tend to rely on ActiveWorkbook and ActiveCell being set on the Application object. What is different when the application is running embedded?

I also noticed other anomalous behavior both in Excel and Powerpoint when running in this embedded state.

Thanks.
Posted 09 Oct, 2013 14:48:36 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Hello Stuart,

I open a presentation in PP 2013, activate the embedded Excel sheet and press a key combination handled by this code in my test add-in (Excel):

private void adxKeyboardShortcut1_Action(object sender) {
    Excel.Range r = ExcelApp.ActiveCell;
    if (r == null)
        MessageBox.Show("ActiveCell is null");
    else 
        MessageBox.Show(r.Address);
}


When I press the combination for the first time, I get two messageboxes: 1) "ActiveCell is null" and 2) the cell address. Consequent keypresses show the second message box only. I've tried using ExcelApp.Selection instead of ExcelApp.ActiveCell and get the same result. The problem goes away if I use System.Diagnostics.Debug.WriteLine() instead of MessageBox.Show(). I don't have words.

Hope this helps.


Andrei Smolin
Add-in Express Team Leader
Posted 10 Oct, 2013 06:39:16 Top
Stuart Kolodner




Posts: 35
Joined: 2009-10-09
Andrei, sounds like it basically works for you; ActiveCell is set except for that very first time. Is that correct?

Been looking at this more ... appears that some of the code I wrote to work around various issues doesn't work when embedded. The issues seem to revolve around the sheet not being active and/or ActiveCell not being set.

One problem ... I set the owner on my WPF dialogs by getting the active window from win32. This works great when running standaloe. However, when a dialog is displayed while embedded, the ActiveCell is no longer set and the dialog isn't really parented by the window . So calls from the dialog into the Excel object model don't work (raises exceptions). Plus the Powerpoint presentation isn't disabled while the dialog is displayed.

Another case ... I do stuff off a timer to make sure Excel exits edit mode. This doesn't work since the embedded spreadsheet is deactivated when the timer goes off. The Excel object model raises exceptions if the sheet isn't active.

Any ideas? Is there a way to tell that the application is embedded and disable my add-in in that case? Or is there a way that the embedded app can "lock" it's UI while its busy?
Posted 11 Oct, 2013 10:44:42 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Stuart Kolodner writes:
Is there a way to tell that the application is embedded and disable my add-in in that case?


Your add-in can find out that it is used in an embedded workbook, see Workbook.Container at http://msdn.microsoft.com/en-us/library/office/ff834401(v=office.15).aspx.


Andrei Smolin
Add-in Express Team Leader
Posted 14 Oct, 2013 06:53:41 Top