473,387 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

outlook hangs with COM add-in

Help! I created a COM addin using vb.net based on the KB article
302896 (http://support.microsoft.com/default...;en-us;302896).
The problem is Outlook remains in memory when after it. I know the
problem is in the OnStartupComplete function. If I comment this
function out, Outlook closes properly. I have added a GC.Collect at
the end, but that doesn't work either. I don't thing the
"oCommandBars = Nothing" is actually getting rid of the CommandBar,
but I'm not sure. Here is the code that makes outlook hang (Straight
from the Knowledge Base):

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete

Dim oCommandBars As CommandBars
Dim oStandardBar As CommandBar

On Error Resume Next
' Set up a custom button on the "Standard" command bar.
oCommandBars = applicationObject.CommandBars
If oCommandBars Is Nothing Then
' Outlook has the CommandBars collection on the Explorer
object.
oCommandBars =
applicationObject.ActiveExplorer.CommandBars
End If

oStandardBar = oCommandBars.Item("Standard")
If oStandardBar Is Nothing Then
' Access names its main toolbar Database.

oStandardBar = oCommandBars.Item("Database")

End If

' In case the button was not deleted, use the exiting one.
MyButton = oStandardBar.Controls.Item("My Custom Button")
If MyButton Is Nothing Then

MyButton = oStandardBar.Controls.Add(1)
With MyButton
.Caption = "My Custom Button"
.Style = MsoButtonStyle.msoButtonCaption

' The following items are optional, but recommended.
' The Tag property lets you quickly find the control
' and helps MSO keep track of it when more than
' one application window is visible. The property is
required
' by some Office applications and should be provided.

.Tag = "My Custom Button"

' The OnAction property is optional but recommended.
' It should be set to the ProgID of the add-in, so
that if
' the add-in is not loaded when a user clicks the
button,
' MSO loads the add-in automatically and then raises
' the Click event for the add-in to handle.

.OnAction = "!<MyCOMAddin.Connect>"

.Visible = True
End With
End If

' Display a simple message to show which application you
started in.
MsgBox("Started in " & applicationObject.Name & ".")
oStandardBar = Nothing
oCommandBars = Nothing
End Sub
Nov 20 '05 #1
4 1756
Damian,
Have you tried using System.Runtime.InteropServices.Marshal.ReleaseComO bject
on each of the Outlook objects to ensure that your .NET based add-in has
release all the Outlook objects?

Hope this helps
Jay

"damian" <de**************@spamgourmet.com> wrote in message
news:bc**************************@posting.google.c om...
Help! I created a COM addin using vb.net based on the KB article
302896 (http://support.microsoft.com/default...;en-us;302896).
The problem is Outlook remains in memory when after it. I know the
problem is in the OnStartupComplete function. If I comment this
function out, Outlook closes properly. I have added a GC.Collect at
the end, but that doesn't work either. I don't thing the
"oCommandBars = Nothing" is actually getting rid of the CommandBar,
but I'm not sure. Here is the code that makes outlook hang (Straight
from the Knowledge Base):

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete

Dim oCommandBars As CommandBars
Dim oStandardBar As CommandBar

On Error Resume Next
' Set up a custom button on the "Standard" command bar.
oCommandBars = applicationObject.CommandBars
If oCommandBars Is Nothing Then
' Outlook has the CommandBars collection on the Explorer
object.
oCommandBars =
applicationObject.ActiveExplorer.CommandBars
End If

oStandardBar = oCommandBars.Item("Standard")
If oStandardBar Is Nothing Then
' Access names its main toolbar Database.

oStandardBar = oCommandBars.Item("Database")

End If

' In case the button was not deleted, use the exiting one.
MyButton = oStandardBar.Controls.Item("My Custom Button")
If MyButton Is Nothing Then

MyButton = oStandardBar.Controls.Add(1)
With MyButton
.Caption = "My Custom Button"
.Style = MsoButtonStyle.msoButtonCaption

' The following items are optional, but recommended.
' The Tag property lets you quickly find the control
' and helps MSO keep track of it when more than
' one application window is visible. The property is
required
' by some Office applications and should be provided.

.Tag = "My Custom Button"

' The OnAction property is optional but recommended.
' It should be set to the ProgID of the add-in, so
that if
' the add-in is not loaded when a user clicks the
button,
' MSO loads the add-in automatically and then raises
' the Click event for the add-in to handle.

.OnAction = "!<MyCOMAddin.Connect>"

.Visible = True
End With
End If

' Display a simple message to show which application you
started in.
MsgBox("Started in " & applicationObject.Name & ".")
oStandardBar = Nothing
oCommandBars = Nothing
End Sub

Nov 20 '05 #2
No I haven't. Could you please give me an example of how to do that? Thanks.

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:<u$*************@TK2MSFTNGP11.phx.gbl>...
Damian,
Have you tried using System.Runtime.InteropServices.Marshal.ReleaseComO bject
on each of the Outlook objects to ensure that your .NET based add-in has
release all the Outlook objects?

Hope this helps
Jay

"damian" <de**************@spamgourmet.com> wrote in message
news:bc**************************@posting.google.c om...
Help! I created a COM addin using vb.net based on the KB article
302896 (http://support.microsoft.com/default...;en-us;302896).
The problem is Outlook remains in memory when after it. I know the
problem is in the OnStartupComplete function. If I comment this
function out, Outlook closes properly. I have added a GC.Collect at
the end, but that doesn't work either. I don't thing the
"oCommandBars = Nothing" is actually getting rid of the CommandBar,
but I'm not sure. Here is the code that makes outlook hang (Straight
from the Knowledge Base):

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete

Dim oCommandBars As CommandBars
Dim oStandardBar As CommandBar

On Error Resume Next
' Set up a custom button on the "Standard" command bar.
oCommandBars = applicationObject.CommandBars
If oCommandBars Is Nothing Then
' Outlook has the CommandBars collection on the Explorer
object.
oCommandBars =
applicationObject.ActiveExplorer.CommandBars
End If

oStandardBar = oCommandBars.Item("Standard")
If oStandardBar Is Nothing Then
' Access names its main toolbar Database.

oStandardBar = oCommandBars.Item("Database")

End If

' In case the button was not deleted, use the exiting one.
MyButton = oStandardBar.Controls.Item("My Custom Button")
If MyButton Is Nothing Then

MyButton = oStandardBar.Controls.Add(1)
With MyButton
.Caption = "My Custom Button"
.Style = MsoButtonStyle.msoButtonCaption

' The following items are optional, but recommended.
' The Tag property lets you quickly find the control
' and helps MSO keep track of it when more than
' one application window is visible. The property is
required
' by some Office applications and should be provided.

.Tag = "My Custom Button"

' The OnAction property is optional but recommended.
' It should be set to the ProgID of the add-in, so
that if
' the add-in is not loaded when a user clicks the
button,
' MSO loads the add-in automatically and then raises
' the Click event for the add-in to handle.

.OnAction = "!<MyCOMAddin.Connect>"

.Visible = True
End With
End If

' Display a simple message to show which application you
started in.
MsgBox("Started in " & applicationObject.Name & ".")
oStandardBar = Nothing
oCommandBars = Nothing
End Sub

Nov 20 '05 #3
Damian,
Did you try looking up ReleaseComObject in the help?

Here are a couple of links to sample Outlook Add-ins that use
ReleaseComObject.

http://msdn.microsoft.com/library/de...addinvbnet.asp

http://msdn.microsoft.com/library/de...hatsNew2k3.asp

Hope this helps
Jay
"damian" <de**************@spamgourmet.com> wrote in message
news:bc**************************@posting.google.c om...
No I haven't. Could you please give me an example of how to do that? Thanks.
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message

news:<u$*************@TK2MSFTNGP11.phx.gbl>...
Damian,
Have you tried using System.Runtime.InteropServices.Marshal.ReleaseComO bject on each of the Outlook objects to ensure that your .NET based add-in has
release all the Outlook objects?

Hope this helps
Jay

"damian" <de**************@spamgourmet.com> wrote in message
news:bc**************************@posting.google.c om...
Help! I created a COM addin using vb.net based on the KB article
302896 (http://support.microsoft.com/default...;en-us;302896). The problem is Outlook remains in memory when after it. I know the
problem is in the OnStartupComplete function. If I comment this
function out, Outlook closes properly. I have added a GC.Collect at
the end, but that doesn't work either. I don't thing the
"oCommandBars = Nothing" is actually getting rid of the CommandBar,
but I'm not sure. Here is the code that makes outlook hang (Straight
from the Knowledge Base):

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete

Dim oCommandBars As CommandBars
Dim oStandardBar As CommandBar

On Error Resume Next
' Set up a custom button on the "Standard" command bar.
oCommandBars = applicationObject.CommandBars
If oCommandBars Is Nothing Then
' Outlook has the CommandBars collection on the Explorer
object.
oCommandBars =
applicationObject.ActiveExplorer.CommandBars
End If

oStandardBar = oCommandBars.Item("Standard")
If oStandardBar Is Nothing Then
' Access names its main toolbar Database.

oStandardBar = oCommandBars.Item("Database")

End If

' In case the button was not deleted, use the exiting one.
MyButton = oStandardBar.Controls.Item("My Custom Button")
If MyButton Is Nothing Then

MyButton = oStandardBar.Controls.Add(1)
With MyButton
.Caption = "My Custom Button"
.Style = MsoButtonStyle.msoButtonCaption

' The following items are optional, but recommended.
' The Tag property lets you quickly find the control
' and helps MSO keep track of it when more than
' one application window is visible. The property is
required
' by some Office applications and should be provided.

.Tag = "My Custom Button"

' The OnAction property is optional but recommended.
' It should be set to the ProgID of the add-in, so
that if
' the add-in is not loaded when a user clicks the
button,
' MSO loads the add-in automatically and then raises
' the Click event for the add-in to handle.

.OnAction = "!<MyCOMAddin.Connect>"

.Visible = True
End With
End If

' Display a simple message to show which application you
started in.
MsgBox("Started in " & applicationObject.Name & ".")
oStandardBar = Nothing
oCommandBars = Nothing
End Sub

Nov 20 '05 #4
I actually have tried this, but it never worked. I always ran into a
problem with this line: Imports Outlook =
Microsoft.Office.Interop.Outlook

I added Microsoft Outlook 9.0 Object Library, not 10.0. I am dealing
with Outlook 2000. I'm guessing that's what causes the import
problem. I also had a problem with the article because you cannot
download the sample through the link (odc_oladdinvbnet.exe), it is
very frustrating.

Another interesting note is this. I cannot get Outlook 2000 to
shutdown properly when I add a custom button based off of article
302896. However, when I use article 302896 at home with Outlook XP,
it does work. Does this make sense?

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:<OX**************@TK2MSFTNGP10.phx.gbl>...
Damian,
Did you try looking up ReleaseComObject in the help?

Here are a couple of links to sample Outlook Add-ins that use
ReleaseComObject.

http://msdn.microsoft.com/library/de...addinvbnet.asp

http://msdn.microsoft.com/library/de...hatsNew2k3.asp

Hope this helps
Jay
"damian" <de**************@spamgourmet.com> wrote in message
news:bc**************************@posting.google.c om...
No I haven't. Could you please give me an example of how to do that?

Thanks.

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message

news:<u$*************@TK2MSFTNGP11.phx.gbl>...
Damian,
Have you tried using System.Runtime.InteropServices.Marshal.ReleaseComO bject on each of the Outlook objects to ensure that your .NET based add-in has
release all the Outlook objects?

Hope this helps
Jay

"damian" <de**************@spamgourmet.com> wrote in message
news:bc**************************@posting.google.c om...
> Help! I created a COM addin using vb.net based on the KB article
> 302896 (http://support.microsoft.com/default...;en-us;302896). > The problem is Outlook remains in memory when after it. I know the
> problem is in the OnStartupComplete function. If I comment this
> function out, Outlook closes properly. I have added a GC.Collect at
> the end, but that doesn't work either. I don't thing the
> "oCommandBars = Nothing" is actually getting rid of the CommandBar,
> but I'm not sure. Here is the code that makes outlook hang (Straight
> from the Knowledge Base):
>
> Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
> Extensibility.IDTExtensibility2.OnStartupComplete
>
> Dim oCommandBars As CommandBars
> Dim oStandardBar As CommandBar
>
> On Error Resume Next
> ' Set up a custom button on the "Standard" command bar.
> oCommandBars = applicationObject.CommandBars
> If oCommandBars Is Nothing Then
> ' Outlook has the CommandBars collection on the Explorer
> object.
> oCommandBars =
> applicationObject.ActiveExplorer.CommandBars
> End If
>
> oStandardBar = oCommandBars.Item("Standard")
> If oStandardBar Is Nothing Then
> ' Access names its main toolbar Database.
>
> oStandardBar = oCommandBars.Item("Database")
>
> End If
>
> ' In case the button was not deleted, use the exiting one.
> MyButton = oStandardBar.Controls.Item("My Custom Button")
> If MyButton Is Nothing Then
>
> MyButton = oStandardBar.Controls.Add(1)
> With MyButton
> .Caption = "My Custom Button"
> .Style = MsoButtonStyle.msoButtonCaption
>
> ' The following items are optional, but recommended.
> ' The Tag property lets you quickly find the control
> ' and helps MSO keep track of it when more than
> ' one application window is visible. The property is
> required
> ' by some Office applications and should be provided.
>
> .Tag = "My Custom Button"
>
> ' The OnAction property is optional but recommended.
> ' It should be set to the ProgID of the add-in, so
> that if
> ' the add-in is not loaded when a user clicks the
> button,
> ' MSO loads the add-in automatically and then raises
> ' the Click event for the add-in to handle.
>
> .OnAction = "!<MyCOMAddin.Connect>"
>
> .Visible = True
> End With
> End If
>
> ' Display a simple message to show which application you
> started in.
> MsgBox("Started in " & applicationObject.Name & ".")
>
>
> oStandardBar = Nothing
> oCommandBars = Nothing
>
>
> End Sub

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marcel Stör | last post by:
Hi all, I'm trying to add a user property to an Outlook contact item. VisualStudio tells me that the method signature was like this: UserProperties.Add(string Name,Outlook.OlUserPropertyType...
1
by: Jonathan Pinto | last post by:
I was wondering if it would be possible to snapshot an access report to Outlook, and have fields come in the To: and Cc: fields, and also the subject field of the email as well. Right now, I am...
0
by: Marcel Stör | last post by:
Hi all, I'm trying to add a user property to an Outlook contact item. VisualStudio tells me that the method signature was like this: UserProperties.Add(string Name,Outlook.OlUserPropertyType...
2
by: Stephen Noronha | last post by:
I was able to add the "Microsoft Outlook" COM Component but now the application does not launch at all. it does not give an error at the sametime it just hangs at this point: Dim OutlookApp As...
4
by: Nicole | last post by:
I found this code below to use to send emails using VB with Outlook. However, it gives these errors. 'Send' is ambiguous across the inherited interfaces 'Outlook._MailItem' and...
7
by: John | last post by:
Hi I am using the following code to automate outlook from within MS Access; Dim O As Object O = CreateObject("Outlook.Application") The problem is that I am getting the following error on...
1
by: jeff.boggs | last post by:
Hello, I have a problem inserting HTML from a Word document into a new Outlook mail message. The message ends up losing all of the formatting and the image that is supposed to appear at the top...
3
by: mwolowski | last post by:
Hello, I'd like to add tasks, appointments, etc using c# to outlook For example i added reference using OutLook = Microsoft.Office.Interop.Outlook; and the code: 1. ---------------------...
4
by: Andy | last post by:
Hi, I have a C# application and I'd like it to use Outlook 2003 to send messages. I don't want to send them programmaticlly though; I just want to open the New Messge window, set the...
0
by: DianaC | last post by:
Hi. I have to generate and send emails from C#.net 2.0 and have to use outlook. I am using Redemption to bypass the outlook security checks, but have the same problem when using CDO. I create an...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.