OnDisconnection

  • Thread starter Thread starter Lars Roland
  • Start date Start date
L

Lars Roland

Hi

I have an outlook addin, when outlook shutdown I try to save some tempoary
data from this addin in the register database. I do this in the
OnDisconnection, event that fires before closing outlook.

I have the folowing code:


-------------------------------------------------------------
Private Sub IDTExtensibility2_OnDisconnection(ByVal RemoveMode _
As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)

Dim objCB As Office.CommandBar
On Error Resume Next
Set objCB = golApp.ActiveExplorer.CommandBars("myAddin")
regCreate_Key_Value HKEY_CURRENT_USER, modControl.REG_KEY, "leftValue", objCB.Left
regCreate_Key_Value HKEY_CURRENT_USER, modControl.REG_KEY, "topValue", objCB.Top
regCreate_Key_Value HKEY_CURRENT_USER, modControl.REG_KEY, "positionValue", objCB.position

'If UserClosed, then remove the command bar
If RemoveMode = ext_dm_UserClosed Then
Set objCB = golApp.ActiveExplorer.CommandBars("myaddin")
objCB.Delete
End If
'Tear down the class
gBaseClass.UnInitHandler
Set gBaseClass = Nothing
End Sub
-------------------------------------------------------------


the commandbar, I try to save the position of, is created as tempoary, so
I am afraid that I cannot read the position data in the onDisconnection
event.

Is there a method to dalay the destruction of the commandbar so that I
can read these values ?. Another solution would be to place the code
that saves these values in an event that fires at a time where the
commandbar is still intact.



Regards

Lars Roland
 
On_Disconnection will not fire when Outlook is closed if any Outlook objects
are instantiated. So by the time it fires the command bar is out of scope.
You can trap the Explorer.Close event for every Explorer that might be open
and get the command bar at that point if you can.

It looks like you might be using Explorer wrapper classes since your code is
similar to that in the ItemsCB COM addin template. If so you should have no
problem handling the Explorer.Close even or even Explorer.Deactivate.




Lars Roland said:
Hi

I have an outlook addin, when outlook shutdown I try to save some tempoary
data from this addin in the register database. I do this in the
OnDisconnection, event that fires before closing outlook.

I have the folowing code:


-------------------------------------------------------------
Private Sub IDTExtensibility2_OnDisconnection(ByVal RemoveMode _
As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)

Dim objCB As Office.CommandBar
On Error Resume Next
Set objCB = golApp.ActiveExplorer.CommandBars("myAddin")
regCreate_Key_Value HKEY_CURRENT_USER, modControl.REG_KEY, "leftValue", objCB.Left
regCreate_Key_Value HKEY_CURRENT_USER, modControl.REG_KEY, "topValue", objCB.Top
regCreate_Key_Value HKEY_CURRENT_USER, modControl.REG_KEY,
"positionValue", objCB.position
 
On_Disconnection will not fire when Outlook is closed if any Outlook objects
are instantiated. So by the time it fires the command bar is out of scope.
You can trap the Explorer.Close event for every Explorer that might be open
and get the command bar at that point if you can.

It looks like you might be using Explorer wrapper classes since your code is
similar to that in the ItemsCB COM addin template. If so you should have no
problem handling the Explorer.Close even or even Explorer.Deactivate.

Yes my code is inspired by ItemsCB and it uses Explore wrapper classes, I
have tried to intercept the commandbar in the ecplore.close event, but
already here it is to late. Eg. I have the folowing code in my explore
wrapper class

Private Sub Expl_Close()
Dim objCB As Office.CommandBar
On Error Resume Next

' Save the position
Set objCB = Expl.CommandBars(modControl.COMMANDBAR_NAME)
regCreate_Key_Value HKEY_CURRENT_USER, modControl.REG_KEY, "leftValue", 10
regCreate_Key_Value HKEY_CURRENT_USER, modControl.REG_KEY, topValue", objCB.Top
regCreate_Key_Value HKEY_CURRENT_USER, modControl.REG_KEY, "positionValue", objCB.position

modOutlExpl.KillExpl m_nID, Me
Set Expl = Nothing
If golApp.Explorers.Count <= 1 Then
gBaseClass.UnInitHandler
End If
End Sub

The values that objCB.Top, and objCB.Left contains at this point are noth
the correct ones (eg. it contains zero), is there somewhere else I can
interzept the destruction of the outlook explore objects, and still get my
hands on the correct values.


Regards.

Lars Roland
 
As I said, you might have to trap Explorer.Deactivate and see if that works
for you. If it does you might end up writing the values a number of times
due to Explorer activations and deactivations but it should work in that
event handler.




Lars Roland said:
Yes my code is inspired by ItemsCB and it uses Explore wrapper classes, I
have tried to intercept the commandbar in the ecplore.close event, but
already here it is to late. Eg. I have the folowing code in my explore
wrapper class

Private Sub Expl_Close()
Dim objCB As Office.CommandBar
On Error Resume Next

' Save the position
Set objCB = Expl.CommandBars(modControl.COMMANDBAR_NAME)
regCreate_Key_Value HKEY_CURRENT_USER, modControl.REG_KEY, "leftValue", 10
regCreate_Key_Value HKEY_CURRENT_USER, modControl.REG_KEY, topValue", objCB.Top
regCreate_Key_Value HKEY_CURRENT_USER, modControl.REG_KEY,
"positionValue", objCB.position
 
Back
Top