|
-
Aug 3rd, 2005, 08:32 AM
#1
Thread Starter
Member
Outlook AddinInstance_onconnection
1. When I create outlook object [set objoutlook=createobject("Outlook.Application")] will the addinInstance_OnConnection() will be executed. If so, is it immediately after its created or its asynchoronous.
2. And also addinInstance_Onconnection calls the InitHandler procedure only when either Explorers.count or Inspectors.count is not equal to zero. When outlook opens how the count will be zero.
-
Aug 3rd, 2005, 10:13 AM
#2
Re: Outlook AddinInstance_onconnection
The OnConnection event should not require you to create your own Outlook instance. You can set a public outlook application object = to the outlook application instance that is passed in to the procedure. This is the proper way. 
VB Code:
Option Explicit
Public moApp As Outlook.Application
Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
set moApp = Application
'...
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 3rd, 2005, 10:32 AM
#3
Thread Starter
Member
Re: Outlook AddinInstance_onconnection
actually i am creating my own outlook object from a procedure in a class module. In that case will the addinInstance_OnConnection () be executed??
-
Aug 3rd, 2005, 10:37 AM
#4
Thread Starter
Member
Re: Outlook AddinInstance_onconnection
VB Code:
Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
On Error Resume Next
'Evaluate ConnectMode
Select Case ConnectMode
Case ext_cm_Startup
Case ext_cm_AfterStartup
Case ext_cm_CommandLine
Case ext_cm_Startup
End Select
'Don't call InitHandler if Explorers.Count = 0 and Inspectors.Count = 0
If Application.Explorers.Count = 0 And Application.Inspectors.Count = 0 Then
Exit Sub
End If
'AddInInst represents COMAddIn object
'Create and Initialize a base class
gBaseClass.InitHandler Application, AddInInst.ProgId
'DebugWrite "IDT2 OnConnection"
End Sub
Method where i create another outlook object is below.
Public Sub Display()
Dim blnNew As Boolean
Dim myFolder As MAPIFolder
Dim myNameSpc As NameSpace
On Error Resume Next
If golApp Is Nothing Then "Open outlook if it is not already open
blnEnableEmail = GetSetting("shsmith", "EnableMail", "EMAIL", True)
If blnEnableEmail Then
Set olOut = CreateObject("Outlook.Application")
Set myNameSpc = olOut.GetNamespace("MAPI")
Set myFolder = myNameSpc.GetDefaultFolder(olFolderInbox)
myfolder.Display
'Set objOutlook = olOut
'Set golApp = olOut
'golApp.ActiveExplorer.Activate
Set olOut = Nothing
Set myNameSpc = Nothing
blnOutCreated = True
End If
Else
blnOutCreated = True
End If
If blnOutCreated Then
Set objCB = golApp.ActiveExplorer.CommandBars("SHSMITH") ' Test if the Items toolbar already exists
If Err Then
blnNew = True
' Create a new items toolbar.
Set objCB = golApp.ActiveExplorer.CommandBars.Add _
(Name:="SHSMITH", Position:=msoBarRight, Temporary:=False)
Set objCBPop = objCB.Controls.Add(Type:=msoControlPopup)
With objCBPop
.Caption = "SHSMITH"
.ToolTipText = "Attach To Correspondence"
End With
Set objCBButton = CreateAddInCommandBarButton(gstrProgID, objCBPop, _
"Attach Email To Correspondence", "SHSMITH", "Attach To Email Correspondence", 1757, False, msoButtonCaption)
End If
blnOutCreated = False
End If
'Display toolbar if new
If blnNew Then objCB.Visible = True
end sub
INITHANDLER LOOKS LIKE THIS.
Friend Sub InitHandler(olApp As Outlook.Application, strProgID As String)
On Error Resume Next
'Declared WithEvents
'Instantiate a public module-level Outlook application variable
Set golApp = olApp
Set objOutlook = olApp
gstrProgID = strProgID
'CBOutlookItems objOutlook.ActiveExplorer.CurrentFolder
End Sub
Last edited by RobDog888; Aug 3rd, 2005 at 10:50 AM.
Reason: Added vbcode tags for easier reading
-
Aug 3rd, 2005, 10:54 AM
#5
Re: Outlook AddinInstance_onconnection
Ok, your line here: gBaseClass.InitHandler Application, AddInInst.ProgId is passing the Application object to your inithandler where your setting your public app var golApp = to it. Thats fine except that an addin usually depends on Outlook starting up on its own. Not too sure if an addin can start Outlook seeing how the addin will not be connected nor have any Application object to pass into the OnConnection event. Sounds like your logic may need improving but what does your addin do anyways?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 3rd, 2005, 11:12 AM
#6
Thread Starter
Member
Re: Outlook AddinInstance_onconnection
my addin will create a command bar on the outlook.When the button is clicked after selceting an item from a folder, the item object will be passed to VB app which will save the item in the VB application.
In the same way,when a mail is sent the dll will pick it up from the sent items folder and pass the object again to VB app which will save the item in the application.
The thing is, When the VB app is run if outlook is not open then a new outlook has to be opened else if outlook is already open, then only the button needs to be added to the existing outlook instance.
currently we have a custom built dll that is working fine, but unfortunately the contract developer took the source with him and we have only the dll. We are trying to code it again.
-
Aug 3rd, 2005, 11:15 AM
#7
Thread Starter
Member
Re: Outlook AddinInstance_onconnection
And also currently the display method opens new outlook but in addininstance_onconnection procedure since Explorers and Inspectors counts are zero the button is not displayed.
And also display method opens new outlook even though an instance is already opened by the user.
-
Aug 3rd, 2005, 11:23 AM
#8
Re: Outlook AddinInstance_onconnection
Ok, got a little better picture of whats going on. You VB app will shell Outlook if its not running. Then it will only create a toolbar button if it was already running?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 3rd, 2005, 12:12 PM
#9
Thread Starter
Member
Re: Outlook AddinInstance_onconnection
VB app will not Shell outlook ...COM DLL will shell outlook if its not running. COM DLL will create the toolbar button if it is already running.
-
Aug 3rd, 2005, 12:40 PM
#10
Re: Outlook AddinInstance_onconnection
This COM dll is the Outlook Add-In, correct? If so it needs Outlook to be running first so it can load th Add_In.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 3rd, 2005, 12:44 PM
#11
Thread Starter
Member
Re: Outlook AddinInstance_onconnection
so do you mean to say that from the outlook com addin we will not be able to shell outlook??.
-
Aug 3rd, 2005, 12:55 PM
#12
Re: Outlook AddinInstance_onconnection
No, I'm not saying that but it would be a new separate instance of Outlook and would not be a Trusted instance and would incur all the security popups from Outlook.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 3rd, 2005, 01:01 PM
#13
Thread Starter
Member
Re: Outlook AddinInstance_onconnection
i am able to create a new instance if there isnt one already but the problem is it is not executing the inithandler procedure as app.explorers.count =0 and this condition is checked in addininstance_onconnection, where the inithandler is also called.
because of this...i am not able to create buttons.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|