Posts 1 - 10 of 15
First | Prev. | 1 2 | Next | Last
|
|
mio
Guest
|
Hi,
I am trying to close a presentation which has be opened programmatically before.
The window of the presentation is closed, but the presentation itself is still present in the presentation collection.
Could you please advise.
Thanks |
|
Posted 17 Jun, 2016 05:07:19
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18817
Joined: 2006-05-11
|
Hello Fabian,
I can't reproduce the issue using a sample add-in project having three Ribbon buttons with the event handlers shown below.
Make sure that you release every COM object created in the code of your add-in. Also, turn off all other COM add-ins.
Andrei Smolin
Add-in Express Team Leader
private void adxRibbonButton1_OnClick(object sender, IRibbonControl control, bool pressed) {
PowerPoint.Presentations presentations = PowerPointApp.Presentations;
PowerPoint.Presentation presentation = presentations.Add(Microsoft.Office.Core.MsoTriState.msoCTrue);
Marshal.ReleaseComObject(presentation); presentation = null;
Marshal.ReleaseComObject(presentations); presentations = null;
}
private void adxRibbonButton2_OnClick(object sender, IRibbonControl control, bool pressed) {
PowerPoint.Presentations presentations = PowerPointApp.Presentations;
PowerPoint.Presentation presentation = presentations[presentations.Count];
presentation.Close();
Marshal.ReleaseComObject(presentation); presentation = null;
Marshal.ReleaseComObject(presentations); presentations = null;
}
private void adxRibbonButton3_OnClick(object sender, IRibbonControl control, bool pressed) {
PowerPoint.Presentations presentations = PowerPointApp.Presentations;
MessageBox.Show(presentations.Count.ToString());
PowerPoint.Presentation presentation = presentations[presentations.Count];
MessageBox.Show(presentation.FullName);
Marshal.ReleaseComObject(presentation); presentation = null;
Marshal.ReleaseComObject(presentations); presentations = null;
} |
|
Posted 20 Jun, 2016 06:31:41
|
|
Top
|
|
mio
Guest
|
Hi Andrei,
I am trying to close the presentation in the same event code I am opening the presentation in.
The presentation is opened by using the Open-Command on an existing presentation on the HDD.
I have an example here:
private void adxRibbonButton1_OnClick(object sender, IRibbonControl control, bool pressed)
{
PowerPoint.Presentations presis = PowerPointApp.Presentations;
PowerPoint._Presentation newPresi = presis.Open(@"Y:BUG_83176_convert chart type issue.pptx");
newPresi.Close();
Marshal.ReleaseComObject(newPresi);
//presis still contains the newPresi
Marshal.ReleaseComObject(presis);
}
|
|
Posted 20 Jun, 2016 07:29:44
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18817
Joined: 2006-05-11
|
Fabian,
I've modified the code by adding these buttons:
private void adxRibbonButton4_OnClick(object sender, IRibbonControl control, bool pressed) {
PowerPoint.Presentations presentations = PowerPointApp.Presentations;
System.Diagnostics.Debug.WriteLine("!!! 1. " + presentations.Count.ToString());
PowerPoint.Presentation presentation = presentations.Open(@"D:ProfileDocumentsgroupedShapes.pptx");
System.Diagnostics.Debug.WriteLine("!!! 2. " + presentations.Count.ToString());
presentation.Close();
System.Diagnostics.Debug.WriteLine("!!! 3. " + presentations.Count.ToString());
Marshal.ReleaseComObject(presentation);
System.Diagnostics.Debug.WriteLine("!!! 4. " + presentations.Count.ToString());
Marshal.ReleaseComObject(presentations);
//adxRibbonButton5_OnClick(null, null, false);
}
private void adxRibbonButton5_OnClick(object sender, IRibbonControl control, bool pressed) {
PowerPoint.Presentations presentations = PowerPointApp.Presentations;
for (int i = 1; i <= presentations.Count; i++) {
PowerPoint.Presentation presentation = presentations[presentations.Count];
System.Diagnostics.Debug.WriteLine("!!! " + i.ToString()+ ". " + presentation.FullName);
Marshal.ReleaseComObject(presentation);
}
Marshal.ReleaseComObject(presentations);
}
If you start PowerPoint with the default new presentation and click the first button, it will produce this output:
!!! 1. 1
!!! 2. 1
!!! 3. 1
!!! 4. 1
The first two records are easy: 1) the collection contains the default presentation; 2) opening an existing presentation closes the default one. The last two record are intriguing; I would expect Presentations.Count to be zero. Let's wait a bit, however. If I click the second button, it produces:
!!! adxRibbonButton5_OnClick
!!! adxRibbonButton5_OnClick. end
It looks like the implementation of the Presentations collection has obvious traces of weirdness: it shows an incorrect number of elements while you manipulate with its members but is shows the correct Count after a delay.
I reproduce the issue if I uncomment the last code line of the first event handler. In this case, starting PowerPoint and clicking the first button produces these records:
!!! 1. 1
!!! 2. 1
!!! 3. 1
!!! 4. 1
!!! adxRibbonButton5_OnClick
!!! 1. D:\Profile\Documents\somePresentation.pptx
!!! adxRibbonButton5_OnClick. end
That is, the presentation I opened is listed in the collection *after* I deleted the presentation for the collection. Clicking the second button produces this output:
!!! adxRibbonButton5_OnClick
!!! 1. D:\Profile\Documents\somePresentation.pptx
!!! adxRibbonButton5_OnClick. end
Close PowerPoint and find PowerPoint.exe hanging in the processes list.
I assume the above is a bug in PowerPoint. To bypass the issue, don't walk through the collection elements in the event handler. I'll prepare a sample project and let the PowerPoint team know about the issue; I'll post the link here when I post a message on the General Office Development forum.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 20 Jun, 2016 08:22:04
|
|
Top
|
|
mio
Guest
|
Hi Andrei,
just wanted to ask, if you have already posted the issue in the Office Development forum?
Could you give me a short update.
Thanks. |
|
Posted 04 Jul, 2016 05:10:27
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18817
Joined: 2006-05-11
|
Hello Fabian,
Ah, that's my fault. I haven't done this.
I've created a VSTO add-in and found that the issue is caused by Add-in Express, not by Office. The issue is now filed under #9234 in our bug-tracking database. We will provide you with a fix ASAP.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 04 Jul, 2016 06:55:11
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18817
Joined: 2006-05-11
|
|
Posted 05 Jul, 2016 09:35:50
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18817
Joined: 2006-05-11
|
|
Posted 07 Jul, 2016 07:44:58
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18817
Joined: 2006-05-11
|
Hello Fabian,
In a moment I'll send you an email containing a download link for the assembly which fixes this issue for me. Please let me know if it works for you.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 08 Jul, 2016 07:55:57
|
|
Top
|
|
mio
Guest
|
Hi Andrei,
thanks about the new file.
I will test it tomorrow and let you know if the issue is fixed. |
|
Posted 11 Jul, 2016 10:44:40
|
|
Top
|
|
Posts 1 - 10 of 15
First | Prev. | 1 2 | Next | Last
|