![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Hello,
I wrote an Outlook Add-In for Ol9 and it normally works fine with Outlook2000/XP/2003. I use Redemption and AddInMon. Therefore I'm not using IDTExtensibility2. I'm trapping Explorer_Close Event and On_disconnection for releasing objects (and I really release all objects). I do not use CreateObject because of problems with script stoppers. But in some cases the add-in causes troubles. Some people using the add-in have the Resiliency problem with the well-known error message by disabling the add-in. Some people are getting the "Microsoft Outlook encountered a problem and..." message after closing Outlook. Although error messages the functionality of the add-in always works fine. I commented out error handling and in most cases nothing changed. No error message or crash during Outlook sessions. In some cases the problems were saved (and that's really strange). I tested a lot, but I didn't get these errors. And I was testing many Outlook versions with different operating systems and virus scanners. I know the ItemsCB example. But because of using AddInMon the code is different. And I'm not using classes like it's in ItemsCB. But I don't think that can cause the problems. Now I'm desperate, because the add-in is working fine in some cases and it's causing these errors in other cases. Here is a part of my code: (I hope it's not too much!) Private Declare Function GetCurrentProcessId Lib "kernel32.dll" () As Long Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long 'Outlook Variablen Private WithEvents moApplication As Outlook.Application Private WithEvents moNameSpace As Outlook.NameSpace Private WithEvents moActiveExplorer As Outlook.Explorer Private msProgID As String Private moContactsFolder As Outlook.MAPIFolder Private WithEvents moContactItems As Outlook.Items Private moCalendarFolder As Outlook.MAPIFolder Private WithEvents moCalendarItems As Outlook.Items Private moTaskFolder As Outlook.MAPIFolder Private WithEvents moTaskItems As Outlook.Items Private moDeleteFolder As Outlook.MAPIFolder Private WithEvents moDeleteItems As Outlook.Items Private obContactItem As Object Private moContactItem As Object Private obDistListItem As Object Private moDistListItem As Object Private obCalendarItem As Object Private moCalendarItem As Object Private obTasksItem As Object Private moTasksItem As Object 'Office Variablen Dim WithEvents objPropertiesButton As Office.CommandBarButton Dim WithEvents objUserAdminButton As Office.CommandBarButton Dim WithEvents objSynchButton As Office.CommandBarButton Dim WithEvents objAktualButton As Office.CommandBarButton Dim WithEvents objImportButton As Office.CommandBarButton Dim WithEvents objExportButton As Office.CommandBarButton Dim WithEvents objRegButton As Office.CommandBarButton Dim WithEvents objHelpButton As Office.CommandBarButton Private Sub AddinInstance_OnAddInsUpdate(custom() As Variant) 'On Error Resume Next 'DebugWrite "AddinInstance_OnAddInsUpdate" Call Registry.DeleteDisable End Sub Private Sub AddinInstance_OnBeginShutdown(custom() As Variant) 'On Error Resume Next 'DebugWrite "AddinInstance_OnBeginShutdown" Call Registry.DeleteDisable End Sub Private Sub AddinInstance_OnConnection(ByVal Application As Object, _ ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _ ByVal AddInInst As Object, custom() As Variant) Dim lngPID As Long Dim lngThreadID As Long Dim iDeleteAnswer As Integer On Error Resume Next Call Registry.DeleteDisable If Application.Explorers.Count 0 Then 'Outlook launched with UI If Not TypeName(Application.ActiveExplorer) = "Nothing" Then 'Initialisieren Set moApplication = Application Set DB.OlApp = Application Set moNameSpace = moApplication.GetNamespace("MAPI") Set moActiveExplorer = Application.ActiveExplorer msProgID = AddInInst.ProgId 'Folder für gelöschte Objekte Set moDeleteFolder = moNameSpace.GetDefaultFolder(olFolderDeletedItems) Set moDeleteItems = moDeleteFolder.Items 'Licence.gbRegVersuch = False Licence.gfalscherLizenzCode = False Licence.gbLizenzAbgelaufen = False Licence.gbZuVielUser = False DB.gImport = False DB.gExport = False DB.gItemAdd = False DB.gSynch = False DB.gTransaktionsUeberpruefung = False DB.gVerbindungFehler = False DB.gbAddUser = False DB.gbErsterUser = False 'Sprache festlegen If moApplication.Application.LanguageSettings.Languag eID(msoLanguageIDUI) = 1031 Then Sprachen.gsSprache = "deutsch" ElseIf moApplication.Application.LanguageSettings.Languag eID(msoLanguageIDUI) = 1040 Then Sprachen.gsSprache = "ital" End If Call Sprachen.InitMsgBox 'Version auslesen If Left(moApplication.Version, 1) = "9" Then DB.gOutlookVersion = 9 ElseIf Left(moApplication.Version, 2) = "10" Then DB.gOutlookVersion = 10 ElseIf Left(moApplication.Version, 2) = "11" Then DB.gOutlookVersion = 11 End If '------------------------------------------------------------------- '1.) Ist GAW aktiviert? Call Registry.RegistryAktivAuslesen If Registry.gsAktivString = "Nein" Then DB.giDBProgrammAktiv = 0 DB.giAutoSynch = 0 'Kontakte Call Registry.RegistryContactFolderIDAuslesen If DB.gstrDBContactsFolderEntryID "" Then Set moContactsFolder = moNameSpace.GetFolderFromID(DB.gstrDBContactsFolde rEntryID) Set moContactItems = moContactsFolder.Items End If 'Kalender Call Registry.RegistryCalendarFolderIDAuslesen If DB.gstrDBCalendarFolderEntryID "" Then Set moCalendarFolder = moNameSpace.GetFolderFromID(DB.gstrDBCalendarFolde rEntryID) Set moCalendarItems = moCalendarFolder.Items End If 'Aufgaben Call Registry.RegistryTaskFolderIDAuslesen If DB.gstrDBTasksFolderEntryID "" Then Set moTaskFolder = moNameSpace.GetFolderFromID(DB.gstrDBTasksFolderEn tryID) Set moTaskItems = moTaskFolder.Items End If Call MenuBar Exit Sub Else DB.giDBProgrammAktiv = 1 End If '2.) DB Verbindung testen If DBVerbindungstest(False) = False Then 'Keine Verbindung!!!!! iDeleteAnswer = MsgBox(gsMsgBox(33), vbYesNo) If iDeleteAnswer = vbYes Then Call Registry.RegistryAktivSchreiben("Nein") 'Kontakte Call Registry.RegistryContactFolderIDAuslesen If DB.gstrDBContactsFolderEntryID "" Then Set moContactsFolder = moNameSpace.GetFolderFromID(DB.gstrDBContactsFolde rEntryID) Set moContactItems = moContactsFolder.Items End If 'Kalender Call Registry.RegistryCalendarFolderIDAuslesen If DB.gstrDBCalendarFolderEntryID "" Then Set moCalendarFolder = moNameSpace.GetFolderFromID(DB.gstrDBCalendarFolde rEntryID) Set moCalendarItems = moCalendarFolder.Items End If 'Aufgaben Call Registry.RegistryTaskFolderIDAuslesen If DB.gstrDBTasksFolderEntryID "" Then Set moTaskFolder = moNameSpace.GetFolderFromID(DB.gstrDBTasksFolderEn tryID) Set moTaskItems = moTaskFolder.Items End If DB.giDBProgrammAktiv = 0 DB.giAutoSynch = 0 MsgBox gsMsgBox(34) Call MenuBar Exit Sub Else 'ODBC Einstellungen öffnen Dim RetVal As Long Dim SysDir As String SysDir = Space$(256) RetVal = modUserID.GetSystemDirectory(SysDir, Len(SysDir)) If RetVal 0 Then WebLink.ShellExec Left$(SysDir, RetVal) & "\odbcad32.exe", vbNormalFocus End If DB.giDBProgrammAktiv = 0 DB.giAutoSynch = 0 'Kontakte Call Registry.RegistryContactFolderIDAuslesen If DB.gstrDBContactsFolderEntryID "" Then Set moContactsFolder = moNameSpace.GetFolderFromID(DB.gstrDBContactsFolde rEntryID) Set moContactItems = moContactsFolder.Items End If 'Kalender Call Registry.RegistryCalendarFolderIDAuslesen If DB.gstrDBCalendarFolderEntryID "" Then Set moCalendarFolder = moNameSpace.GetFolderFromID(DB.gstrDBCalendarFolde rEntryID) Set moCalendarItems = moCalendarFolder.Items End If 'Aufgaben Call Registry.RegistryTaskFolderIDAuslesen If DB.gstrDBTasksFolderEntryID "" Then Set moTaskFolder = moNameSpace.GetFolderFromID(DB.gstrDBTasksFolderEn tryID) Set moTaskItems = moTaskFolder.Items End If Call MenuBar Exit Sub End If End If '3.) Lizensierung Call CheckLizenz '4.) Menü Call MenuBar '5.) User Properties If HoleUserProperties = False Then If Licence.gfalscherLizenzCode = False And Licence.gbZuVielUser = False And Licence.gbLizenzAbgelaufen = False Then Call frmAddUser.Show(vbModal) End If End If DoEvents 'Kontakte Call Registry.RegistryContactFolderIDAuslesen If DB.gstrDBContactsFolderEntryID "" Then Set moContactsFolder = moNameSpace.GetFolderFromID(DB.gstrDBContactsFolde rEntryID) Set moContactItems = moContactsFolder.Items End If 'Kalender Call Registry.RegistryCalendarFolderIDAuslesen If DB.gstrDBCalendarFolderEntryID "" Then Set moCalendarFolder = moNameSpace.GetFolderFromID(DB.gstrDBCalendarFolde rEntryID) Set moCalendarItems = moCalendarFolder.Items End If 'Aufgaben Call Registry.RegistryTaskFolderIDAuslesen If DB.gstrDBTasksFolderEntryID "" Then Set moTaskFolder = moNameSpace.GetFolderFromID(DB.gstrDBTasksFolderEn tryID) Set moTaskItems = moTaskFolder.Items End If 'Lizenz If Licence.gfalscherLizenzCode = False And Licence.gbZuVielUser = False And Licence.gbLizenzAbgelaufen = False Then DB.giDBProgrammAktiv = 1 Call frmSynch.Synchronisieren Else DB.giDBProgrammAktiv = 0 DB.giAutoSynch = 0 End If 'Benutzerrechte If DB.gbErsterUser = True Then DB.giAdmin = 1 End If If DB.giAdmin = 0 Then objUserAdminButton.Enabled = False Else objUserAdminButton.Enabled = True End If 'Routinen für Ersteinstiege-------------------------------------- If DB.gbAddUser = True Then If DB.gbErsterUser = True Then iDeleteAnswer = MsgBox(gsMsgBox(39), vbYesNo) If iDeleteAnswer = vbYes Then Call ExportSteuern End If DB.gbErsterUser = False Else iDeleteAnswer = MsgBox(gsMsgBox(40), vbYesNo) If iDeleteAnswer = vbYes Then Call SynchSteuern End If End If DB.gbAddUser = False End If '---------------------------------------------------------------- End If Else 'Outlook launched without UI 'Get Outlook ProcessID (same as current process ID since Add-In runs in-process lngPID = GetCurrentProcessId lngThreadID = GetCurrentThreadId If IsAddInMonProcess = False Then 'Launch AddInMonitor, supplying Add-In ProgID, Outlook PID, ThreadID Call Registry.RegistryAppPathAuslesen Shell Registry.gApplicationPath & "\AddInMon.exe /n " & AddInInst.ProgId _ & " /p " & lngPID & " /t " & lngThreadID End If End If End Sub Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode _ As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant) 'On Error Resume Next If RemoveMode = ext_dm_UserClosed Then 'User shutdown removed COM Add-in 'Cleanup custom toolbars by deleting them 'Office If Not objPropertiesButton Is Nothing Then Set objPropertiesButton = Nothing End If If Not objUserAdminButton Is Nothing Then Set objUserAdminButton = Nothing End If If Not objSynchButton Is Nothing Then Set objSynchButton = Nothing End If If Not objAktualButton Is Nothing Then Set objAktualButton = Nothing End If If Not objImportButton Is Nothing Then Set objImportButton = Nothing End If If Not objExportButton Is Nothing Then Set objExportButton = Nothing End If If Not objRegButton Is Nothing Then Set objRegButton = Nothing End If If Not objHelpButton Is Nothing Then Set objHelpButton = Nothing End If Else 'Host shutdown End If Call UnInitHandler End Sub Private Sub AddinInstance_OnStartupComplete(custom() As Variant) 'On Error Resume Next 'DebugWrite "AddinInstance OnStartupComplete" End Sub Private Sub moActiveExplorer_Close() 'On Error Resume Next 'Explorer Object If Not moActiveExplorer Is Nothing Then Set moActiveExplorer = Nothing End If If moApplication.Explorers.Count = 1 Then 'Fenster If Not frmAddUser Is Nothing Then Unload frmAddUser Set frmAddUser = Nothing End If If Not frmAddFolder Is Nothing Then Unload frmAddFolder Set frmAddFolder = Nothing End If If Not frmBenutzerverwaltung Is Nothing Then Unload frmBenutzerverwaltung Set frmBenutzerverwaltung = Nothing End If If Not frmExport Is Nothing Then Unload frmExport Set frmExport = Nothing End If If Not frmVorExport Is Nothing Then Unload frmVorExport Set frmVorExport = Nothing End If If Not frmImport Is Nothing Then Unload frmImport Set frmImport = Nothing End If If Not frmManSynch Is Nothing Then Unload frmManSynch Set frmManSynch = Nothing End If If Not frmManSynchTable Is Nothing Then Unload frmManSynchTable Set frmManSynchTable = Nothing End If If Not frmProperties Is Nothing Then Unload frmProperties Set frmProperties = Nothing End If If Not frmReaktivierung Is Nothing Then Unload frmReaktivierung Set frmReaktivierung = Nothing End If If Not frmReAktivUpdate Is Nothing Then Unload frmReAktivUpdate Set frmReAktivUpdate = Nothing End If If Not frmRegister Is Nothing Then Unload frmRegister Set frmRegister = Nothing End If If Not frmSynch Is Nothing Then Unload frmSynch Set frmSynch = Nothing End If Call UnInitHandler End If End Sub Sub UnInitHandler() On Error Resume Next 'Outlook If Not obContactItem Is Nothing Then Set obContactItem = Nothing End If If Not moContactItem Is Nothing Then Set moContactItem = Nothing End If If Not obDistListItem Is Nothing Then Set obDistListItem = Nothing End If If Not moDistListItem Is Nothing Then Set moDistListItem = Nothing End If If Not obCalendarItem Is Nothing Then Set obCalendarItem = Nothing End If If Not moCalendarItem Is Nothing Then Set moCalendarItem = Nothing End If If Not obTasksItem Is Nothing Then Set obTasksItem = Nothing End If If Not moTasksItem Is Nothing Then Set moTasksItem = Nothing End If If Not moContactItems Is Nothing Then Set moContactItems = Nothing End If If Not moDeleteItems Is Nothing Then Set moDeleteItems = Nothing End If If Not moContactsFolder Is Nothing Then Set moContactsFolder = Nothing End If If Not moDeleteFolder Is Nothing Then Set moDeleteFolder = Nothing End If If Not moNameSpace Is Nothing Then Set moNameSpace = Nothing End If If Not DB.OlApp Is Nothing Then Set DB.OlApp = Nothing End If If Not moApplication Is Nothing Then Set moApplication = Nothing End If End Sub Maybe someone can help me? |
#2
|
|||
|
|||
![]()
Christoph, one thing that has bitten me in the butt before is not
catching my exceptions. If an exception is thrown and it is not caught, Outlook will try to disable your add-in. Rog Christoph wrote: Hello, I wrote an Outlook Add-In for Ol9 and it normally works fine with Outlook2000/XP/2003. I use Redemption and AddInMon. Therefore I'm not using IDTExtensibility2. I'm trapping Explorer_Close Event and On_disconnection for releasing objects (and I really release all objects). I do not use CreateObject because of problems with script stoppers. But in some cases the add-in causes troubles. Some people using the add-in have the Resiliency problem with the well-known error message by disabling the add-in. Some people are getting the "Microsoft Outlook encountered a problem and..." message after closing Outlook. Although error messages the functionality of the add-in always works fine. I commented out error handling and in most cases nothing changed. No error message or crash during Outlook sessions. In some cases the problems were saved (and that's really strange). I tested a lot, but I didn't get these errors. And I was testing many Outlook versions with different operating systems and virus scanners. I know the ItemsCB example. But because of using AddInMon the code is different. And I'm not using classes like it's in ItemsCB. But I don't think that can cause the problems. Now I'm desperate, because the add-in is working fine in some cases and it's causing these errors in other cases. Here is a part of my code: (I hope it's not too much!) Private Declare Function GetCurrentProcessId Lib "kernel32.dll" () As Long Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long 'Outlook Variablen Private WithEvents moApplication As Outlook.Application Private WithEvents moNameSpace As Outlook.NameSpace Private WithEvents moActiveExplorer As Outlook.Explorer Private msProgID As String Private moContactsFolder As Outlook.MAPIFolder Private WithEvents moContactItems As Outlook.Items Private moCalendarFolder As Outlook.MAPIFolder Private WithEvents moCalendarItems As Outlook.Items Private moTaskFolder As Outlook.MAPIFolder Private WithEvents moTaskItems As Outlook.Items Private moDeleteFolder As Outlook.MAPIFolder Private WithEvents moDeleteItems As Outlook.Items Private obContactItem As Object Private moContactItem As Object Private obDistListItem As Object Private moDistListItem As Object Private obCalendarItem As Object Private moCalendarItem As Object Private obTasksItem As Object Private moTasksItem As Object 'Office Variablen Dim WithEvents objPropertiesButton As Office.CommandBarButton Dim WithEvents objUserAdminButton As Office.CommandBarButton Dim WithEvents objSynchButton As Office.CommandBarButton Dim WithEvents objAktualButton As Office.CommandBarButton Dim WithEvents objImportButton As Office.CommandBarButton Dim WithEvents objExportButton As Office.CommandBarButton Dim WithEvents objRegButton As Office.CommandBarButton Dim WithEvents objHelpButton As Office.CommandBarButton Private Sub AddinInstance_OnAddInsUpdate(custom() As Variant) 'On Error Resume Next 'DebugWrite "AddinInstance_OnAddInsUpdate" Call Registry.DeleteDisable End Sub Private Sub AddinInstance_OnBeginShutdown(custom() As Variant) 'On Error Resume Next 'DebugWrite "AddinInstance_OnBeginShutdown" Call Registry.DeleteDisable End Sub Private Sub AddinInstance_OnConnection(ByVal Application As Object, _ ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _ ByVal AddInInst As Object, custom() As Variant) Dim lngPID As Long Dim lngThreadID As Long Dim iDeleteAnswer As Integer On Error Resume Next Call Registry.DeleteDisable If Application.Explorers.Count 0 Then 'Outlook launched with UI If Not TypeName(Application.ActiveExplorer) = "Nothing" Then 'Initialisieren Set moApplication = Application Set DB.OlApp = Application Set moNameSpace = moApplication.GetNamespace("MAPI") Set moActiveExplorer = Application.ActiveExplorer msProgID = AddInInst.ProgId 'Folder für gelöschte Objekte Set moDeleteFolder = moNameSpace.GetDefaultFolder(olFolderDeletedItems) Set moDeleteItems = moDeleteFolder.Items 'Licence.gbRegVersuch = False Licence.gfalscherLizenzCode = False Licence.gbLizenzAbgelaufen = False Licence.gbZuVielUser = False DB.gImport = False DB.gExport = False DB.gItemAdd = False DB.gSynch = False DB.gTransaktionsUeberpruefung = False DB.gVerbindungFehler = False DB.gbAddUser = False DB.gbErsterUser = False 'Sprache festlegen If moApplication.Application.LanguageSettings.Languag eID(msoLanguageIDUI) = 1031 Then Sprachen.gsSprache = "deutsch" ElseIf moApplication.Application.LanguageSettings.Languag eID(msoLanguageIDUI) = 1040 Then Sprachen.gsSprache = "ital" End If Call Sprachen.InitMsgBox 'Version auslesen If Left(moApplication.Version, 1) = "9" Then DB.gOutlookVersion = 9 ElseIf Left(moApplication.Version, 2) = "10" Then DB.gOutlookVersion = 10 ElseIf Left(moApplication.Version, 2) = "11" Then DB.gOutlookVersion = 11 End If '------------------------------------------------------------------- '1.) Ist GAW aktiviert? Call Registry.RegistryAktivAuslesen If Registry.gsAktivString = "Nein" Then DB.giDBProgrammAktiv = 0 DB.giAutoSynch = 0 'Kontakte Call Registry.RegistryContactFolderIDAuslesen If DB.gstrDBContactsFolderEntryID "" Then Set moContactsFolder = moNameSpace.GetFolderFromID(DB.gstrDBContactsFolde rEntryID) Set moContactItems = moContactsFolder.Items End If 'Kalender Call Registry.RegistryCalendarFolderIDAuslesen If DB.gstrDBCalendarFolderEntryID "" Then Set moCalendarFolder = moNameSpace.GetFolderFromID(DB.gstrDBCalendarFolde rEntryID) Set moCalendarItems = moCalendarFolder.Items End If 'Aufgaben Call Registry.RegistryTaskFolderIDAuslesen If DB.gstrDBTasksFolderEntryID "" Then Set moTaskFolder = moNameSpace.GetFolderFromID(DB.gstrDBTasksFolderEn tryID) Set moTaskItems = moTaskFolder.Items End If Call MenuBar Exit Sub Else DB.giDBProgrammAktiv = 1 End If '2.) DB Verbindung testen If DBVerbindungstest(False) = False Then 'Keine Verbindung!!!!! iDeleteAnswer = MsgBox(gsMsgBox(33), vbYesNo) If iDeleteAnswer = vbYes Then Call Registry.RegistryAktivSchreiben("Nein") 'Kontakte Call Registry.RegistryContactFolderIDAuslesen If DB.gstrDBContactsFolderEntryID "" Then Set moContactsFolder = moNameSpace.GetFolderFromID(DB.gstrDBContactsFolde rEntryID) Set moContactItems = moContactsFolder.Items End If 'Kalender Call Registry.RegistryCalendarFolderIDAuslesen If DB.gstrDBCalendarFolderEntryID "" Then Set moCalendarFolder = moNameSpace.GetFolderFromID(DB.gstrDBCalendarFolde rEntryID) Set moCalendarItems = moCalendarFolder.Items End If 'Aufgaben Call Registry.RegistryTaskFolderIDAuslesen If DB.gstrDBTasksFolderEntryID "" Then Set moTaskFolder = moNameSpace.GetFolderFromID(DB.gstrDBTasksFolderEn tryID) Set moTaskItems = moTaskFolder.Items End If DB.giDBProgrammAktiv = 0 DB.giAutoSynch = 0 MsgBox gsMsgBox(34) Call MenuBar Exit Sub Else 'ODBC Einstellungen öffnen Dim RetVal As Long Dim SysDir As String SysDir = Space$(256) RetVal = modUserID.GetSystemDirectory(SysDir, Len(SysDir)) If RetVal 0 Then WebLink.ShellExec Left$(SysDir, RetVal) & "\odbcad32.exe", vbNormalFocus End If DB.giDBProgrammAktiv = 0 DB.giAutoSynch = 0 'Kontakte Call Registry.RegistryContactFolderIDAuslesen If DB.gstrDBContactsFolderEntryID "" Then Set moContactsFolder = moNameSpace.GetFolderFromID(DB.gstrDBContactsFolde rEntryID) Set moContactItems = moContactsFolder.Items End If 'Kalender Call Registry.RegistryCalendarFolderIDAuslesen If DB.gstrDBCalendarFolderEntryID "" Then Set moCalendarFolder = moNameSpace.GetFolderFromID(DB.gstrDBCalendarFolde rEntryID) Set moCalendarItems = moCalendarFolder.Items End If 'Aufgaben Call Registry.RegistryTaskFolderIDAuslesen If DB.gstrDBTasksFolderEntryID "" Then Set moTaskFolder = moNameSpace.GetFolderFromID(DB.gstrDBTasksFolderEn tryID) Set moTaskItems = moTaskFolder.Items End If Call MenuBar Exit Sub End If End If '3.) Lizensierung Call CheckLizenz '4.) Menü Call MenuBar '5.) User Properties If HoleUserProperties = False Then If Licence.gfalscherLizenzCode = False And Licence.gbZuVielUser = False And Licence.gbLizenzAbgelaufen = False Then Call frmAddUser.Show(vbModal) End If End If DoEvents 'Kontakte Call Registry.RegistryContactFolderIDAuslesen If DB.gstrDBContactsFolderEntryID "" Then Set moContactsFolder = moNameSpace.GetFolderFromID(DB.gstrDBContactsFolde rEntryID) Set moContactItems = moContactsFolder.Items End If 'Kalender Call Registry.RegistryCalendarFolderIDAuslesen If DB.gstrDBCalendarFolderEntryID "" Then Set moCalendarFolder = moNameSpace.GetFolderFromID(DB.gstrDBCalendarFolde rEntryID) Set moCalendarItems = moCalendarFolder.Items End If 'Aufgaben Call Registry.RegistryTaskFolderIDAuslesen If DB.gstrDBTasksFolderEntryID "" Then Set moTaskFolder = moNameSpace.GetFolderFromID(DB.gstrDBTasksFolderEn tryID) Set moTaskItems = moTaskFolder.Items End If 'Lizenz If Licence.gfalscherLizenzCode = False And Licence.gbZuVielUser = False And Licence.gbLizenzAbgelaufen = False Then DB.giDBProgrammAktiv = 1 Call frmSynch.Synchronisieren Else DB.giDBProgrammAktiv = 0 DB.giAutoSynch = 0 End If 'Benutzerrechte If DB.gbErsterUser = True Then DB.giAdmin = 1 End If If DB.giAdmin = 0 Then objUserAdminButton.Enabled = False Else objUserAdminButton.Enabled = True End If 'Routinen für Ersteinstiege-------------------------------------- If DB.gbAddUser = True Then If DB.gbErsterUser = True Then iDeleteAnswer = MsgBox(gsMsgBox(39), vbYesNo) If iDeleteAnswer = vbYes Then Call ExportSteuern End If DB.gbErsterUser = False Else iDeleteAnswer = MsgBox(gsMsgBox(40), vbYesNo) If iDeleteAnswer = vbYes Then Call SynchSteuern End If End If DB.gbAddUser = False End If '---------------------------------------------------------------- End If Else 'Outlook launched without UI 'Get Outlook ProcessID (same as current process ID since Add-In runs in-process lngPID = GetCurrentProcessId lngThreadID = GetCurrentThreadId If IsAddInMonProcess = False Then 'Launch AddInMonitor, supplying Add-In ProgID, Outlook PID, ThreadID Call Registry.RegistryAppPathAuslesen Shell Registry.gApplicationPath & "\AddInMon.exe /n " & AddInInst.ProgId _ & " /p " & lngPID & " /t " & lngThreadID End If End If End Sub Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode _ As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant) 'On Error Resume Next If RemoveMode = ext_dm_UserClosed Then 'User shutdown removed COM Add-in 'Cleanup custom toolbars by deleting them 'Office If Not objPropertiesButton Is Nothing Then Set objPropertiesButton = Nothing End If If Not objUserAdminButton Is Nothing Then Set objUserAdminButton = Nothing End If If Not objSynchButton Is Nothing Then Set objSynchButton = Nothing End If If Not objAktualButton Is Nothing Then Set objAktualButton = Nothing End If If Not objImportButton Is Nothing Then Set objImportButton = Nothing End If If Not objExportButton Is Nothing Then Set objExportButton = Nothing End If If Not objRegButton Is Nothing Then Set objRegButton = Nothing End If If Not objHelpButton Is Nothing Then Set objHelpButton = Nothing End If Else 'Host shutdown End If Call UnInitHandler End Sub Private Sub AddinInstance_OnStartupComplete(custom() As Variant) 'On Error Resume Next 'DebugWrite "AddinInstance OnStartupComplete" End Sub Private Sub moActiveExplorer_Close() 'On Error Resume Next 'Explorer Object If Not moActiveExplorer Is Nothing Then Set moActiveExplorer = Nothing End If If moApplication.Explorers.Count = 1 Then 'Fenster If Not frmAddUser Is Nothing Then Unload frmAddUser Set frmAddUser = Nothing End If If Not frmAddFolder Is Nothing Then Unload frmAddFolder Set frmAddFolder = Nothing End If If Not frmBenutzerverwaltung Is Nothing Then Unload frmBenutzerverwaltung Set frmBenutzerverwaltung = Nothing End If If Not frmExport Is Nothing Then Unload frmExport Set frmExport = Nothing End If If Not frmVorExport Is Nothing Then Unload frmVorExport Set frmVorExport = Nothing End If If Not frmImport Is Nothing Then Unload frmImport Set frmImport = Nothing End If If Not frmManSynch Is Nothing Then Unload frmManSynch Set frmManSynch = Nothing End If If Not frmManSynchTable Is Nothing Then Unload frmManSynchTable Set frmManSynchTable = Nothing End If If Not frmProperties Is Nothing Then Unload frmProperties Set frmProperties = Nothing End If If Not frmReaktivierung Is Nothing Then Unload frmReaktivierung Set frmReaktivierung = Nothing End If If Not frmReAktivUpdate Is Nothing Then Unload frmReAktivUpdate Set frmReAktivUpdate = Nothing End If If Not frmRegister Is Nothing Then Unload frmRegister Set frmRegister = Nothing End If If Not frmSynch Is Nothing Then Unload frmSynch Set frmSynch = Nothing End If Call UnInitHandler End If End Sub Sub UnInitHandler() On Error Resume Next 'Outlook If Not obContactItem Is Nothing Then Set obContactItem = Nothing End If If Not moContactItem Is Nothing Then Set moContactItem = Nothing End If If Not obDistListItem Is Nothing Then Set obDistListItem = Nothing End If If Not moDistListItem Is Nothing Then Set moDistListItem = Nothing End If If Not obCalendarItem Is Nothing Then Set obCalendarItem = Nothing End If If Not moCalendarItem Is Nothing Then Set moCalendarItem = Nothing End If If Not obTasksItem Is Nothing Then Set obTasksItem = Nothing End If If Not moTasksItem Is Nothing Then Set moTasksItem = Nothing End If If Not moContactItems Is Nothing Then Set moContactItems = Nothing End If If Not moDeleteItems Is Nothing Then Set moDeleteItems = Nothing End If If Not moContactsFolder Is Nothing Then Set moContactsFolder = Nothing End If If Not moDeleteFolder Is Nothing Then Set moDeleteFolder = Nothing End If If Not moNameSpace Is Nothing Then Set moNameSpace = Nothing End If If Not DB.OlApp Is Nothing Then Set DB.OlApp = Nothing End If If Not moApplication Is Nothing Then Set moApplication = Nothing End If End Sub Maybe someone can help me? |
#3
|
|||
|
|||
![]()
Rog,
Thank you for your answer. But I don't know what you're meaning by catching an exception. |
#4
|
|||
|
|||
![]()
I write my COM-addins in C#. So for example
If in the Connect class you had the OnStartupComplete method make sure you put try { } catch(System.Exception ex) { //logging here } in the body of the method. I notice in your "AddinInstance_OnConnection" method you do a lot of processing which of course means things can go wrong. If an exception is thrown and it is not caught Outlook will try to disable your addin. Christoph wrote: Rog, Thank you for your answer. But I don't know what you're meaning by catching an exception. |
#5
|
|||
|
|||
![]()
Christoph,
The code you attached is concerned with startup and shutdown, and if you were having problems with Outlook remaining in memory then it would make sense to focus on how objects get released. But if your add-in is getting disabled that's probably related to something that it is doing with an object, and if it doesn't repro for you it may just be that you aren't testing a particular action on some object. If you can't figure out what the users are doing differently I suggest adding detailed logging to your app so that its operations and errors to a text file that the user can send you. That might seem like extra work but it can save many hours of guessing and wondering. the comment from Rog - "catching exceptions" means handling errors. If your code generates errors that it doesn't handle those errors/exceptions are passed to Outlook, and if it doesn't like it then it will disable your add-in or raise an error message itself "Christoph" wrote in message ups.com... Hello, I wrote an Outlook Add-In for Ol9 and it normally works fine with Outlook2000/XP/2003. I use Redemption and AddInMon. Therefore I'm not using IDTExtensibility2. I'm trapping Explorer_Close Event and On_disconnection for releasing objects (and I really release all objects). I do not use CreateObject because of problems with script stoppers. But in some cases the add-in causes troubles. Some people using the add-in have the Resiliency problem with the well-known error message by disabling the add-in. Some people are getting the "Microsoft Outlook encountered a problem and..." message after closing Outlook. Although error messages the functionality of the add-in always works fine. I commented out error handling and in most cases nothing changed. No error message or crash during Outlook sessions. In some cases the problems were saved (and that's really strange). I tested a lot, but I didn't get these errors. And I was testing many Outlook versions with different operating systems and virus scanners. I know the ItemsCB example. But because of using AddInMon the code is different. And I'm not using classes like it's in ItemsCB. But I don't think that can cause the problems. Now I'm desperate, because the add-in is working fine in some cases and it's causing these errors in other cases. Here is a part of my code: (I hope it's not too much!) Private Declare Function GetCurrentProcessId Lib "kernel32.dll" () As Long Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long 'Outlook Variablen Private WithEvents moApplication As Outlook.Application Private WithEvents moNameSpace As Outlook.NameSpace Private WithEvents moActiveExplorer As Outlook.Explorer Private msProgID As String Private moContactsFolder As Outlook.MAPIFolder Private WithEvents moContactItems As Outlook.Items Private moCalendarFolder As Outlook.MAPIFolder Private WithEvents moCalendarItems As Outlook.Items Private moTaskFolder As Outlook.MAPIFolder Private WithEvents moTaskItems As Outlook.Items Private moDeleteFolder As Outlook.MAPIFolder Private WithEvents moDeleteItems As Outlook.Items Private obContactItem As Object Private moContactItem As Object Private obDistListItem As Object Private moDistListItem As Object Private obCalendarItem As Object Private moCalendarItem As Object Private obTasksItem As Object Private moTasksItem As Object 'Office Variablen Dim WithEvents objPropertiesButton As Office.CommandBarButton Dim WithEvents objUserAdminButton As Office.CommandBarButton Dim WithEvents objSynchButton As Office.CommandBarButton Dim WithEvents objAktualButton As Office.CommandBarButton Dim WithEvents objImportButton As Office.CommandBarButton Dim WithEvents objExportButton As Office.CommandBarButton Dim WithEvents objRegButton As Office.CommandBarButton Dim WithEvents objHelpButton As Office.CommandBarButton Private Sub AddinInstance_OnAddInsUpdate(custom() As Variant) 'On Error Resume Next 'DebugWrite "AddinInstance_OnAddInsUpdate" Call Registry.DeleteDisable End Sub Private Sub AddinInstance_OnBeginShutdown(custom() As Variant) 'On Error Resume Next 'DebugWrite "AddinInstance_OnBeginShutdown" Call Registry.DeleteDisable End Sub Private Sub AddinInstance_OnConnection(ByVal Application As Object, _ ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _ ByVal AddInInst As Object, custom() As Variant) Dim lngPID As Long Dim lngThreadID As Long Dim iDeleteAnswer As Integer On Error Resume Next Call Registry.DeleteDisable If Application.Explorers.Count 0 Then 'Outlook launched with UI If Not TypeName(Application.ActiveExplorer) = "Nothing" Then 'Initialisieren Set moApplication = Application Set DB.OlApp = Application Set moNameSpace = moApplication.GetNamespace("MAPI") Set moActiveExplorer = Application.ActiveExplorer msProgID = AddInInst.ProgId 'Folder für gelöschte Objekte Set moDeleteFolder = moNameSpace.GetDefaultFolder(olFolderDeletedItems) Set moDeleteItems = moDeleteFolder.Items 'Licence.gbRegVersuch = False Licence.gfalscherLizenzCode = False Licence.gbLizenzAbgelaufen = False Licence.gbZuVielUser = False DB.gImport = False DB.gExport = False DB.gItemAdd = False DB.gSynch = False DB.gTransaktionsUeberpruefung = False DB.gVerbindungFehler = False DB.gbAddUser = False DB.gbErsterUser = False 'Sprache festlegen If moApplication.Application.LanguageSettings.Languag eID(msoLanguageIDUI) = 1031 Then Sprachen.gsSprache = "deutsch" ElseIf moApplication.Application.LanguageSettings.Languag eID(msoLanguageIDUI) = 1040 Then Sprachen.gsSprache = "ital" End If Call Sprachen.InitMsgBox 'Version auslesen If Left(moApplication.Version, 1) = "9" Then DB.gOutlookVersion = 9 ElseIf Left(moApplication.Version, 2) = "10" Then DB.gOutlookVersion = 10 ElseIf Left(moApplication.Version, 2) = "11" Then DB.gOutlookVersion = 11 End If '------------------------------------------------------------------- '1.) Ist GAW aktiviert? Call Registry.RegistryAktivAuslesen If Registry.gsAktivString = "Nein" Then DB.giDBProgrammAktiv = 0 DB.giAutoSynch = 0 'Kontakte Call Registry.RegistryContactFolderIDAuslesen If DB.gstrDBContactsFolderEntryID "" Then Set moContactsFolder = moNameSpace.GetFolderFromID(DB.gstrDBContactsFolde rEntryID) Set moContactItems = moContactsFolder.Items End If 'Kalender Call Registry.RegistryCalendarFolderIDAuslesen If DB.gstrDBCalendarFolderEntryID "" Then Set moCalendarFolder = moNameSpace.GetFolderFromID(DB.gstrDBCalendarFolde rEntryID) Set moCalendarItems = moCalendarFolder.Items End If 'Aufgaben Call Registry.RegistryTaskFolderIDAuslesen If DB.gstrDBTasksFolderEntryID "" Then Set moTaskFolder = moNameSpace.GetFolderFromID(DB.gstrDBTasksFolderEn tryID) Set moTaskItems = moTaskFolder.Items End If Call MenuBar Exit Sub Else DB.giDBProgrammAktiv = 1 End If '2.) DB Verbindung testen If DBVerbindungstest(False) = False Then 'Keine Verbindung!!!!! iDeleteAnswer = MsgBox(gsMsgBox(33), vbYesNo) If iDeleteAnswer = vbYes Then Call Registry.RegistryAktivSchreiben("Nein") 'Kontakte Call Registry.RegistryContactFolderIDAuslesen If DB.gstrDBContactsFolderEntryID "" Then Set moContactsFolder = moNameSpace.GetFolderFromID(DB.gstrDBContactsFolde rEntryID) Set moContactItems = moContactsFolder.Items End If 'Kalender Call Registry.RegistryCalendarFolderIDAuslesen If DB.gstrDBCalendarFolderEntryID "" Then Set moCalendarFolder = moNameSpace.GetFolderFromID(DB.gstrDBCalendarFolde rEntryID) Set moCalendarItems = moCalendarFolder.Items End If 'Aufgaben Call Registry.RegistryTaskFolderIDAuslesen If DB.gstrDBTasksFolderEntryID "" Then Set moTaskFolder = moNameSpace.GetFolderFromID(DB.gstrDBTasksFolderEn tryID) Set moTaskItems = moTaskFolder.Items End If DB.giDBProgrammAktiv = 0 DB.giAutoSynch = 0 MsgBox gsMsgBox(34) Call MenuBar Exit Sub Else 'ODBC Einstellungen öffnen Dim RetVal As Long Dim SysDir As String SysDir = Space$(256) RetVal = modUserID.GetSystemDirectory(SysDir, Len(SysDir)) If RetVal 0 Then WebLink.ShellExec Left$(SysDir, RetVal) & "\odbcad32.exe", vbNormalFocus End If DB.giDBProgrammAktiv = 0 DB.giAutoSynch = 0 'Kontakte Call Registry.RegistryContactFolderIDAuslesen If DB.gstrDBContactsFolderEntryID "" Then Set moContactsFolder = moNameSpace.GetFolderFromID(DB.gstrDBContactsFolde rEntryID) Set moContactItems = moContactsFolder.Items End If 'Kalender Call Registry.RegistryCalendarFolderIDAuslesen If DB.gstrDBCalendarFolderEntryID "" Then Set moCalendarFolder = moNameSpace.GetFolderFromID(DB.gstrDBCalendarFolde rEntryID) Set moCalendarItems = moCalendarFolder.Items End If 'Aufgaben Call Registry.RegistryTaskFolderIDAuslesen If DB.gstrDBTasksFolderEntryID "" Then Set moTaskFolder = moNameSpace.GetFolderFromID(DB.gstrDBTasksFolderEn tryID) Set moTaskItems = moTaskFolder.Items End If Call MenuBar Exit Sub End If End If '3.) Lizensierung Call CheckLizenz '4.) Menü Call MenuBar '5.) User Properties If HoleUserProperties = False Then If Licence.gfalscherLizenzCode = False And Licence.gbZuVielUser = False And Licence.gbLizenzAbgelaufen = False Then Call frmAddUser.Show(vbModal) End If End If DoEvents 'Kontakte Call Registry.RegistryContactFolderIDAuslesen If DB.gstrDBContactsFolderEntryID "" Then Set moContactsFolder = moNameSpace.GetFolderFromID(DB.gstrDBContactsFolde rEntryID) Set moContactItems = moContactsFolder.Items End If 'Kalender Call Registry.RegistryCalendarFolderIDAuslesen If DB.gstrDBCalendarFolderEntryID "" Then Set moCalendarFolder = moNameSpace.GetFolderFromID(DB.gstrDBCalendarFolde rEntryID) Set moCalendarItems = moCalendarFolder.Items End If 'Aufgaben Call Registry.RegistryTaskFolderIDAuslesen If DB.gstrDBTasksFolderEntryID "" Then Set moTaskFolder = moNameSpace.GetFolderFromID(DB.gstrDBTasksFolderEn tryID) Set moTaskItems = moTaskFolder.Items End If 'Lizenz If Licence.gfalscherLizenzCode = False And Licence.gbZuVielUser = False And Licence.gbLizenzAbgelaufen = False Then DB.giDBProgrammAktiv = 1 Call frmSynch.Synchronisieren Else DB.giDBProgrammAktiv = 0 DB.giAutoSynch = 0 End If 'Benutzerrechte If DB.gbErsterUser = True Then DB.giAdmin = 1 End If If DB.giAdmin = 0 Then objUserAdminButton.Enabled = False Else objUserAdminButton.Enabled = True End If 'Routinen für Ersteinstiege-------------------------------------- If DB.gbAddUser = True Then If DB.gbErsterUser = True Then iDeleteAnswer = MsgBox(gsMsgBox(39), vbYesNo) If iDeleteAnswer = vbYes Then Call ExportSteuern End If DB.gbErsterUser = False Else iDeleteAnswer = MsgBox(gsMsgBox(40), vbYesNo) If iDeleteAnswer = vbYes Then Call SynchSteuern End If End If DB.gbAddUser = False End If '---------------------------------------------------------------- End If Else 'Outlook launched without UI 'Get Outlook ProcessID (same as current process ID since Add-In runs in-process lngPID = GetCurrentProcessId lngThreadID = GetCurrentThreadId If IsAddInMonProcess = False Then 'Launch AddInMonitor, supplying Add-In ProgID, Outlook PID, ThreadID Call Registry.RegistryAppPathAuslesen Shell Registry.gApplicationPath & "\AddInMon.exe /n " & AddInInst.ProgId _ & " /p " & lngPID & " /t " & lngThreadID End If End If End Sub Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode _ As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant) 'On Error Resume Next If RemoveMode = ext_dm_UserClosed Then 'User shutdown removed COM Add-in 'Cleanup custom toolbars by deleting them 'Office If Not objPropertiesButton Is Nothing Then Set objPropertiesButton = Nothing End If If Not objUserAdminButton Is Nothing Then Set objUserAdminButton = Nothing End If If Not objSynchButton Is Nothing Then Set objSynchButton = Nothing End If If Not objAktualButton Is Nothing Then Set objAktualButton = Nothing End If If Not objImportButton Is Nothing Then Set objImportButton = Nothing End If If Not objExportButton Is Nothing Then Set objExportButton = Nothing End If If Not objRegButton Is Nothing Then Set objRegButton = Nothing End If If Not objHelpButton Is Nothing Then Set objHelpButton = Nothing End If Else 'Host shutdown End If Call UnInitHandler End Sub Private Sub AddinInstance_OnStartupComplete(custom() As Variant) 'On Error Resume Next 'DebugWrite "AddinInstance OnStartupComplete" End Sub Private Sub moActiveExplorer_Close() 'On Error Resume Next 'Explorer Object If Not moActiveExplorer Is Nothing Then Set moActiveExplorer = Nothing End If If moApplication.Explorers.Count = 1 Then 'Fenster If Not frmAddUser Is Nothing Then Unload frmAddUser Set frmAddUser = Nothing End If If Not frmAddFolder Is Nothing Then Unload frmAddFolder Set frmAddFolder = Nothing End If If Not frmBenutzerverwaltung Is Nothing Then Unload frmBenutzerverwaltung Set frmBenutzerverwaltung = Nothing End If If Not frmExport Is Nothing Then Unload frmExport Set frmExport = Nothing End If If Not frmVorExport Is Nothing Then Unload frmVorExport Set frmVorExport = Nothing End If If Not frmImport Is Nothing Then Unload frmImport Set frmImport = Nothing End If If Not frmManSynch Is Nothing Then Unload frmManSynch Set frmManSynch = Nothing End If If Not frmManSynchTable Is Nothing Then Unload frmManSynchTable Set frmManSynchTable = Nothing End If If Not frmProperties Is Nothing Then Unload frmProperties Set frmProperties = Nothing End If If Not frmReaktivierung Is Nothing Then Unload frmReaktivierung Set frmReaktivierung = Nothing End If If Not frmReAktivUpdate Is Nothing Then Unload frmReAktivUpdate Set frmReAktivUpdate = Nothing End If If Not frmRegister Is Nothing Then Unload frmRegister Set frmRegister = Nothing End If If Not frmSynch Is Nothing Then Unload frmSynch Set frmSynch = Nothing End If Call UnInitHandler End If End Sub Sub UnInitHandler() On Error Resume Next 'Outlook If Not obContactItem Is Nothing Then Set obContactItem = Nothing End If If Not moContactItem Is Nothing Then Set moContactItem = Nothing End If If Not obDistListItem Is Nothing Then Set obDistListItem = Nothing End If If Not moDistListItem Is Nothing Then Set moDistListItem = Nothing End If If Not obCalendarItem Is Nothing Then Set obCalendarItem = Nothing End If If Not moCalendarItem Is Nothing Then Set moCalendarItem = Nothing End If If Not obTasksItem Is Nothing Then Set obTasksItem = Nothing End If If Not moTasksItem Is Nothing Then Set moTasksItem = Nothing End If If Not moContactItems Is Nothing Then Set moContactItems = Nothing End If If Not moDeleteItems Is Nothing Then Set moDeleteItems = Nothing End If If Not moContactsFolder Is Nothing Then Set moContactsFolder = Nothing End If If Not moDeleteFolder Is Nothing Then Set moDeleteFolder = Nothing End If If Not moNameSpace Is Nothing Then Set moNameSpace = Nothing End If If Not DB.OlApp Is Nothing Then Set DB.OlApp = Nothing End If If Not moApplication Is Nothing Then Set moApplication = Nothing End If End Sub Maybe someone can help me? |
#6
|
|||
|
|||
![]()
I think I have solved one thing causing the error.
In many functions I'm getting different folders. For Example: .... 'DB.OlApp is a global Object, I'm setting at On_Connection. .... Dim oNameSpace As outlook.NameSpace Dim oPersFolder As outlook.MAPIFolder Set oNameSpace = DB.OlApp.GetNamespace("MAPI") Set oPersFolder = oNameSpace.GetDefaultFolder(olFolderContacts).Pare nt .... Set oPersFolder = Nothing Set oNameSpace = Nothing Now I'm getting my folders without an own namespace variable Dim oPersFolder As outlook.MAPIFolder Set oPersFolder = DB.OlApp.GetNamespace("MAPI").GetDefaultFolder(olF olderContacts).Parent .... Set oPersFolder = Nothing So I think the Script Stopper problem has also something to do with the namespace object, not only with the application object. Would it be a problem to do the same with the namespace object as I'm doing it with the application object? At On_Connection I'm setting a global namespace variable. Then I'm always using the same global namespace object. Like... DB.olNameSpace would then be the global namespace object. And I'm always using that object. Dim oPersFolder As outlook.MAPIFolder Set oPersFolder = DB.olNameSpace.GetDefaultFolder(olFolderContacts). Parent Is this the best solution or should I leave it like that? Set oPersFolder = DB.OlApp.GetNamespace("MAPI").GetDefaultFolder(olF olderContacts).Parent |
#7
|
|||
|
|||
![]()
It is more efficient to declare the namespace variable once at a module or
global level and keep a reference to it, but how you handle that is not going to affect whether or not your add-in gets disabled. "Christoph" wrote in message ups.com... I think I have solved one thing causing the error. In many functions I'm getting different folders. For Example: ... 'DB.OlApp is a global Object, I'm setting at On_Connection. ... Dim oNameSpace As outlook.NameSpace Dim oPersFolder As outlook.MAPIFolder Set oNameSpace = DB.OlApp.GetNamespace("MAPI") Set oPersFolder = oNameSpace.GetDefaultFolder(olFolderContacts).Pare nt ... Set oPersFolder = Nothing Set oNameSpace = Nothing Now I'm getting my folders without an own namespace variable Dim oPersFolder As outlook.MAPIFolder Set oPersFolder = DB.OlApp.GetNamespace("MAPI").GetDefaultFolder(olF olderContacts).Parent ... Set oPersFolder = Nothing So I think the Script Stopper problem has also something to do with the namespace object, not only with the application object. Would it be a problem to do the same with the namespace object as I'm doing it with the application object? At On_Connection I'm setting a global namespace variable. Then I'm always using the same global namespace object. Like... DB.olNameSpace would then be the global namespace object. And I'm always using that object. Dim oPersFolder As outlook.MAPIFolder Set oPersFolder = DB.olNameSpace.GetDefaultFolder(olFolderContacts). Parent Is this the best solution or should I leave it like that? Set oPersFolder = DB.OlApp.GetNamespace("MAPI").GetDefaultFolder(olF olderContacts).Parent |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Strange Outlook Problem when sending HTML Mail | Feezie | Outlook - General Queries | 0 | February 15th 06 05:55 PM |
Strange Outlook Attachment Problem....Please help... | Jim Smith | Outlook - General Queries | 3 | February 10th 06 01:31 PM |
Outlook appoitment strange E-mail | Sue Mosher [MVP-Outlook] | Outlook - Calandaring | 0 | January 25th 06 08:24 PM |
Outlook 2003 calendar developed 2 strange quirks | portmarc | Outlook - Calandaring | 0 | January 25th 06 06:33 AM |
Strange Files | Newsgroups | Outlook - General Queries | 0 | January 22nd 06 03:12 PM |