Posts 1 - 10 of 14
First | Prev. | 1 2 | Next | Last
|
|
Arthur Gascoin
Posts: 13
Joined: 2014-08-27
|
Hi,
I'm searching for setting activewindow in a merged addin context.
I've tried the following lines without results (In Addin1 and Addin2 which are merged in MergeAddin solution) :
ActiveWindow = Me.HostApplication.ActiveWindow => Nothing
ActiveWindow = PowerPointApp.ActiveWindow => Nothing
ActiveWindow = MergedAddin.AddinModule.CurrentInstance.PowerPointApp.ActiveWindow => Nothing
Many thanks,
Kind regards Thibault |
|
Posted 27 Aug, 2014 04:10:38
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18793
Joined: 2006-05-11
|
Hello Thibault,
The ActiveWindow property of the corresponding Office application returns an object representing the window which is currently active. It returns Nothing (null in C#) if there's no such window. The question is: In what event do you call PowerPointApp.ActiveWindow? Does it work if you call it in the Click event of a Ribbon button?
Andrei Smolin
Add-in Express Team Leader |
|
Posted 27 Aug, 2014 05:47:02
|
|
Top
|
|
Arthur Gascoin
Posts: 13
Joined: 2014-08-27
|
Hello Andrei,
Thanks for this quick answer.
ActiveWindow (nor HostApplication, nor PowerPointApp) return Nothing when called from a ribbon button (onClick).
Regards from France, |
|
Posted 27 Aug, 2014 06:02:37
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18793
Joined: 2006-05-11
|
Hello Thibault,
I don't know what is ActiveWindow (I do know what PowerPointApp.ActiveWindow returns).
What is your problem? I presume you are looking for a way to get the active window. If so, call PowerPointApp.Ativewindow in the context of the add-in module in which the Click event of that button is executed.
What is the "merged addin context"? How do you merge add-ins?
Andrei Smolin
Add-in Express Team Leader |
|
Posted 27 Aug, 2014 06:15:51
|
|
Top
|
|
Arthur Gascoin
Posts: 13
Joined: 2014-08-27
|
I Merged my addins following the link below :
http://www.add-in-express.com/creating-addins-blog/2012/11/27/office-excel-addins-one-binary/
I try to access to Power Point (PowerPointApp) from my merged addin.
The following code is on click event from ribbon button and it work great when my addin is not merged :
Dim ActiveWindow As Object = Nothing
Try
ActiveWindow = Me.HostApplication.CurrentInstance.ActiveWindow() '=> Nothing
Catch
End Try
If Not ActiveWindow Is Nothing Then
Select Case Me.HostType
Case ADXOfficeHostApp.ohaPowerPoint
Dim Selection As PowerPoint.Selection = CType(ActiveWindow, PowerPoint.DocumentWindow).Selection
Dim SlideRange As PowerPoint.SlideRange = Selection.SlideRange
For Each SlidePPT As PowerPoint.Slide In SlideRange
'Make my work here
Next
End Select
End If
Thanks again. |
|
Posted 27 Aug, 2014 07:10:39
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18793
Joined: 2006-05-11
|
Hello Thibault,
Dim ActiveWindow As Object = Nothing
Try
ActiveWindow = Me.HostApplication.CurrentInstance.ActiveWindow() '=> Nothing
Catch
End Try
I presume you use Option strict off. Should you use Option Strict On, you'd find that the code fragment above doesn't compile. As to now, this produces a run-time exception which is ignored.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 27 Aug, 2014 09:59:52
|
|
Top
|
|
Arthur Gascoin
Posts: 13
Joined: 2014-08-27
|
Hello,
I'm confuse. You are totaly right I should use Strict option.
Dim ActiveWindow As Object = Nothing
Try
ActiveWindow = trycast(Me.HostApplication,powerpoint.Application).ActiveWindow() '=> Nothing
Catch
End Try
Now more compilation error with strict on :) , but i'm still unable to access host application :(
Regards, |
|
Posted 27 Aug, 2014 11:22:59
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18793
Joined: 2006-05-11
|
Does the code fragment produce an exception?
Andrei Smolin
Add-in Express Team Leader |
|
Posted 28 Aug, 2014 01:16:32
|
|
Top
|
|
Arthur Gascoin
Posts: 13
Joined: 2014-08-27
|
Hello Andrei,
Yes Me.HostApplication is null (nothing in VB) :/
I'm unable to refer to powerpointapp too.
PS: I have send a sample project to Pieter van der Westhuizen.
Regards, |
|
Posted 28 Aug, 2014 02:32:49
|
|
Top
|
|
Thibault Martin
Posts: 13
Joined: 2014-08-27
|
I think my error is related to
- http://www.add-in-express.com/forum/read.php?FID=5&TID=5086
- http://www.add-in-express.com/forum/read.php?FID=5&TID=11546
And moreover :
- http://www.add-in-express.com/creating-addins-blog/2012/11/27/office-excel-addins-one-binary/comment-page-1/#comment-303428
This code produce the following exception :
Private Sub AdxRibbonButton1_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles AdxRibbonButton1.OnClick
Select Case Me.SupportedApps
Case ADXOfficeHostApp.ohaPowerPoint
Me.AdxPowerPointTaskPanesManager1.Items.Clear()
If blActivation Then
Dim ItemPanePP As New AddinExpress.PP.ADXPowerPointTaskPanesCollectionItem
ItemPanePP.TaskPaneClassName = "E1C_PP.E1CPPT_Definition.myTaskPane"
ItemPanePP.AlwaysShowHeader = True
ItemPanePP.CloseButton = True
ItemPanePP.Position = AddinExpress.PP.ADXPowerPointTaskPanePosition.Right
'Not working
Me.AdxPowerPointTaskPanesManager1.Items.Add(ItemPanePP).ShowTaskPane()
'Produce the following exception
AddinExpress.PP.PowerPointContextArgs.InitializeActiveContext()
AddinExpress.PP.2005.dll: N 0001 (0x1) IL
AddinExpress.PP.PowerPointContextArgs..ctor(FormsManager As ADXPowerPointTaskPanesManager)
AddinExpress.PP.2005.dll: N 0070 (0x46) IL
AddinExpress.PP.ADXPowerPointTaskPanesCollectionItem.ShowTaskPane()
AddinExpress.PP.2005.dll: N 0019 (0x13) IL
'End
'Not working
E1C_PP.AddinModule.CurrentInstance.setPane("E1C_PP.E1CPPT_Definition.myTaskPane")
'Produce the following exception
E1C_PP.AddinModule.get_CurrentInstance()
AddinModule.vb: line 0232, col 13, IL 0001 (0x1)
E1C_PP.E1CPPT_Definitions.AddinModule.AdxRibbonButton1_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean)
AddinModule.vb: line 0157, col 25, IL 0132 (0x84)
AddinExpress.MSO.ADXRibbonButton.DoInternalAction(e As ADXRibbonOnActionEventArgs)
E1C_PP.DLL: N 0054 (0x36) IL
'End
ItemPanePP = Nothing
Else
If Me.AdxPowerPointTaskPanesManager1.Items(0).TaskPaneInstance.Visible Then
Me.AdxPowerPointTaskPanesManager1.Items(0).TaskPaneInstance.Hide()
Else
Me.AdxPowerPointTaskPanesManager1.Items(0).TaskPaneInstance.Show()
End If
End If
Case Else
End Select
End Sub
Thanks,
Regards, |
|
Posted 28 Aug, 2014 09:20:33
|
|
Top
|
|
Posts 1 - 10 of 14
First | Prev. | 1 2 | Next | Last
|