<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">

<channel>
	<title>Add-in Express Blog</title>
	
	<link>http://www.add-in-express.com/creating-addins-blog</link>
	<description>All about developing COM add-ins, smart tags and RTD servers in Visual Studio .NET, VSTO and Delphi + Add-in Express</description>
	<lastBuildDate>Fri, 06 Nov 2009 15:04:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Add-inExpressBlog" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>HowTo: Get an attachment size in Outlook 2000 – 2007, part 2</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/11/06/outlook-exact-attachment-size/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/11/06/outlook-exact-attachment-size/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 15:04:01 +0000</pubDate>
		<dc:creator>Dmitry Kostochko</dc:creator>
				<category><![CDATA[HowTo samples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[COM add-ins]]></category>
		<category><![CDATA[MAPI]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=899</guid>
		<description><![CDATA[In the previous sample, I showed how to get the PR_ATTACH_SIZE Extended MAPI property that returns the size of an Attachment object. To be more precise, it returns the size of the attached file and the size of some internal info. In most cases that makeweight does not matter at all]]></description>
			<content:encoded><![CDATA[<p>In the previous sample, I showed <a href="http://www.add-in-express.com/creating-addins-blog/2009/10/23/outlook-attachment-size/">how to get the PR_ATTACH_SIZE Extended MAPI property</a> that returns the size of an Attachment object. To be more precise, it returns the size of the attached file plus the size of some internal info.</p>
<p>In most cases that makeweight does not matter at all since it is very small (about 100-200 bytes), but sometimes it may be excess. In order to get the <strong><span style="text-decoration: underline;">exact</span></strong> size of the attached file, you need to use the PR_ATTACH_DATA_BIN binary property:</p>
<pre class="SrcCode"><code class="vb">
Private Function GetAttachSizeMAPI(ByVal oMAPIObject As Object) As Long

    If (oMAPIObject Is Nothing) Then Return 0

    Dim result As String = 0
    Dim pPropValue As IntPtr = IntPtr.Zero
    Dim IUnk As IntPtr = IntPtr.Zero
    Dim IProperty As IntPtr = IntPtr.Zero
    Try
        MAPI.MAPIInitialize(IntPtr.Zero)
        IUnk = Marshal.GetIUnknownForObject(oMAPIObject)
        ' Outlook 2003 and 2007 ( IMAPIProp )
        Dim res = Marshal.QueryInterface(IUnk, MAPI.guidMAPIProp, IProperty)
        If res = MAPI.S_OK Then
            Dim oMapiProp As Object = Marshal.GetObjectForIUnknown(IProperty)
            Dim iMapiProp As IMAPIProp = TryCast(oMapiProp, IMAPIProp)
            If iMapiProp IsNot Nothing Then
                Try
                    Dim stream As ComTypes.IStream
                    Dim IStream As IntPtr = IntPtr.Zero
                    iMapiProp.OpenProperty( _
                        MAPI.PR_ATTACH_DATA_BIN, _
                        MAPI.guidIStream, 0, 0, _
                        IStream)
                    If IStream &lt;&gt; IntPtr.Zero Then
                        Try
                            stream = TryCast( _
                                Marshal.GetObjectForIUnknown(IStream), _
                                ComTypes.IStream)
                            If stream IsNot Nothing Then
                                Try
                                    Dim stat As ComTypes.STATSTG = Nothing
                                    stream.Stat(stat, STATFLAG.STATFLAG_NONAME)
                                    result = stat.cbSize
                                    Return result
                                Finally
                                    Marshal.ReleaseComObject(stream)
                                End Try
                            End If
                        Finally
                            Marshal.Release(IStream)
                        End Try
                    End If
                Finally
                    Marshal.ReleaseComObject(oMapiProp)
                End Try
            End If
        End If
        ' Outlook 2000 and XP ( IAttach )
        res = Marshal.QueryInterface(IUnk, MAPI.guidMAPIAttach, IProperty)
        If res = MAPI.S_OK Then
            Dim oMapiProp As Object = Marshal.GetObjectForIUnknown(IProperty)
            Dim iMapiProp As IAttach = TryCast(oMapiProp, IAttach)
            If iMapiProp IsNot Nothing Then
                Try
                    Dim stream As ComTypes.IStream
                    Dim IStream As IntPtr = IntPtr.Zero
                    iMapiProp.OpenProperty( _
                        MAPI.PR_ATTACH_DATA_BIN, _
                        MAPI.guidIStream, 0, 0, _
                        IStream)
                    If IStream &lt;&gt; IntPtr.Zero Then
                        Try
                            stream = TryCast( _
                                Marshal.GetObjectForIUnknown(IStream), _
                                ComTypes.IStream)
                            If stream IsNot Nothing Then
                                Try
                                    Dim stat As ComTypes.STATSTG = Nothing
                                    stream.Stat(stat, STATFLAG.STATFLAG_NONAME)
                                    result = stat.cbSize
                                    Return result
                                Finally
                                    Marshal.ReleaseComObject(stream)
                                End Try
                            End If
                        Finally
                            Marshal.Release(IStream)
                        End Try
                    End If
                Finally
                    Marshal.ReleaseComObject(oMapiProp)
                End Try
            End If
        End If
    Finally
        If (pPropValue &lt;&gt; IntPtr.Zero) Then
            MAPI.MAPIFreeBuffer(pPropValue)
        End If
        If (IProperty &lt;&gt; IntPtr.Zero) Then
            Marshal.Release(IProperty)
        End If
        If (IUnk &lt;&gt; IntPtr.Zero) Then
            Marshal.Release(IUnk)
        End If
    End Try
    Return result
End Function
</code></pre>
<p>Personal thanks to François-Denis for his contribution to the <a href="http://www.add-in-express.com/forum/read.php?FID=5&amp;TID=6262">PR_ATTACH_SIZE vs. PR_ATTACH_DATA_BIN properties</a> discussion on our forum.</p>
<h3>You may also be interested in:</h3>
<p><a href="http://www.add-in-express.com/add-in-net/outlook.php">How to program an Outlook COM add-in: ribbon tabs, command bars, task panes</a><br />
<a href="http://www.add-in-express.com/add-in-net/programming-outlook.php">Advanced features for Outlook plug-in development</a><br />
<a href="http://www.add-in-express.com/docs/net-outlook-forms.php">How to develop custom Outlook forms</a></p>
<h3>Available downloads:</h3>
<p>This sample add-in was developed using <a href="http://www.add-in-express.com/add-in-net/">Add-in Express 2009 for Microsoft Office and .net</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-attachment-size-2-cs.zip">C# sample Outlook add-in for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-attachment-size-2-vb.zip">VB.NET sample Outlook add-in for VS 2005</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/11/06/outlook-exact-attachment-size/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo: Get an attachment size in Outlook 2000 – 2007</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/10/23/outlook-attachment-size/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/10/23/outlook-attachment-size/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 09:30:25 +0000</pubDate>
		<dc:creator>Dmitry Kostochko</dc:creator>
				<category><![CDATA[HowTo samples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[COM add-ins]]></category>
		<category><![CDATA[MAPI]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=889</guid>
		<description><![CDATA[The new Size property of the Attachment object was introduced in the Outlook 2007 Object Model. There exist at least two methods of getting the attachment size in older Outlook versions]]></description>
			<content:encoded><![CDATA[<p>The new <a href="http://msdn.microsoft.com/en-us/library/bb207717.aspx">Size</a> property of the <a href="http://msdn.microsoft.com/en-us/library/bb219940.aspx" target=_blank>Attachment</a> object was introduced in the Outlook 2007 Object Model. There exist at least two methods of getting the attachment size in older Outlook versions, that is in Outlook 2003, XP and 2000.</p>
<p>The first method is as follows: you store each attachment in a temporary file, then query the file size, and after that delete that temporary file. The other, and probably a smarter way, is getting the attachment size via the PR_ATTACH_SIZE Extended MAPI property. It is that second method that we are going to scrutinize today.</p>
<p>The DoGetAttachmentSize method is quite simple, the code below processes the <a href="http://msdn.microsoft.com/en-us/library/bb147604.aspx" target=_blank>Attachments</a> collection:</p>
<pre class="SrcCode"><code class="vb">
Private Sub DoGetAttachmentSize(ByRef mail As Outlook._MailItem)
    Dim attachments As Outlook.Attachments = mail.Attachments
    If attachments IsNot Nothing Then
        Try
            If attachments.Count &gt; 0 Then
                Dim Output As String = String.Empty
                For i As Integer = 1 To attachments.Count
                    Dim attach As Outlook.Attachment = attachments.Item(i)
                    If attach IsNot Nothing Then
                        Try
                            Dim size As Long = GetMAPIProp( _
                                attach.MAPIOBJECT, _
                                MAPI.PR_ATTACH_SIZE)
                            Output += "#" + i.ToString() + _
                             ": " + attach.FileName + _
                             " " + size.ToString() + _
                             Environment.NewLine
                        Finally
                            Marshal.ReleaseComObject(attach)
                        End Try
                    End If
                Next i
                If Output &lt;&gt; String.Empty Then MessageBox.Show(Output)
            End If
        Finally
            Marshal.ReleaseComObject(attachments)
        End Try
    End If
End Sub
</code></pre>
<p>In the GetMAPIProp method, you dig for the needed PR_ATTACH_SIZE property. Initialize Extended MAPI, query the right interface, get the <a href="http://msdn.microsoft.com/en-us/library/cc815896.aspx" target=_blank>SPropValue</a> structure and receive the wanted value. Pay attention here to the two calls of QueryInterface. The point is that Outlook 2003 and Outlook 2007 return only the IMAPIProp interface, while Outlook 2000 and Outlook XP return the IAttach interface only. What kind of interface will be implemented in Outlook 2010 is unclear so far, that is why I am leaving the code as is,  with 2 QueryInterface calls:</p>
<pre class="SrcCode"><code class="vb">
Private Function GetMAPIProp( _
    ByVal oMAPIObject As Object, _
    ByVal uiPropertyTag As UInteger) As Long

    If (oMAPIObject Is Nothing) Then Return 0

    Dim result As String = 0
    Dim pPropValue As IntPtr = IntPtr.Zero
    Dim IUnk As IntPtr = IntPtr.Zero
    Dim IProperty As IntPtr = IntPtr.Zero
    Try
        MAPI.MAPIInitialize(IntPtr.Zero)
        IUnk = Marshal.GetIUnknownForObject(oMAPIObject)
        Dim guidMAPIProp As Guid = New Guid(MAPI.IID_IMAPIProp)
        Dim res = Marshal.QueryInterface(IUnk, guidMAPIProp, IProperty)
        If (res &lt;&gt; MAPI.S_OK) Then
            Dim guidMAPIAttach As Guid = New Guid(MAPI.IID_IAttachment)
            Marshal.QueryInterface(IUnk, guidMAPIAttach, IProperty)
            If (res &lt;&gt; MAPI.S_OK) Then Return 0
        End If
        Try
            MAPI.HrGetOneProp(IProperty, uiPropertyTag, pPropValue)
            If (pPropValue = IntPtr.Zero) Then Return 0
            Dim propValue As SPropValue
            propValue = _
                Marshal.PtrToStructure(pPropValue, propValue.GetType())
            result = propValue.Value And UInt32.MaxValue
        Catch ex As System.Exception
            Throw ex
        End Try
    Finally
        If (pPropValue &lt;&gt; IntPtr.Zero) Then
            MAPI.MAPIFreeBuffer(pPropValue)
        End If
        If (IProperty &lt;&gt; IntPtr.Zero) Then
            Marshal.Release(IProperty)
        End If
        If (IUnk &lt;&gt; IntPtr.Zero) Then
            Marshal.Release(IUnk)
        End If
    End Try
    Return result
End Function
</code></pre>
<p>Have a nice weekend. I hope the weather will finally get better here and I will go fishing to enjoy peace and tranquility, at last!</p>
<h3>You may also be interested in:</h3>
<p><a href="http://www.add-in-express.com/add-in-net/outlook.php">How to develop an Outlook COM add-in step-by-step</a><br />
<a href="http://www.add-in-express.com/add-in-net/programming-outlook.php">Advanced features for Outlook toolbars, menus and ribbons</a></p>
<h3>Available downloads:</h3>
<p>This sample add-in was developed using <a href="http://www.add-in-express.com/add-in-net/">Add-in Express 2009 for Microsoft Office and .net</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-attachment-size-cs.zip">C# sample Outlook add-in for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-attachment-size-vb.zip">VB.NET sample Outlook add-in for VS 2005</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/10/23/outlook-attachment-size/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo: Drag and drop onto a minimized Outlook Region and Word Task Pane</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/08/21/drag-drop-minimized-outlook-region/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/08/21/drag-drop-minimized-outlook-region/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 14:44:30 +0000</pubDate>
		<dc:creator>Dmitry Kostochko</dc:creator>
				<category><![CDATA[HowTo samples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[COM add-ins]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=857</guid>
		<description><![CDATA[In one of the previous posts, we examined the possibilities of retrieving properties from Outlook MailItem when dragging this item onto your custom form. Here is that post: How to get properties of an Outlook email item drag-and-dropped onto a .NET form. But what if the Advanced Region is in a Minimized state? In this case the form is hidden and none of the standard events will work...]]></description>
			<content:encoded><![CDATA[<p>In one of the previous posts, we examined the possibilities of retrieving properties from Outlook MailItem when dragging this item onto your custom form. Here is that post: <a title="HowTo: Get properties of an Outlook email item drag-and-dropped onto a .NET form" href="http://www.add-in-express.com/creating-addins-blog/2009/03/20/outlook-email-item-drag-drop/">How to get properties of an Outlook email item drag-and-dropped onto a .NET form</a>. But what if the Advanced Region is in a Minimized state? In this case the form is hidden and none of the standard events will work.</p>
<p>Starting from version 5.1, a new event is available in Add-in Express &#8211; <em>ADXDragOverMinimized</em>. Using this event you can access a dragged item and expand the form. The code of the sample is very plain indeed, and I am not going to publish it here. You can download the samples using the links at the end of this post.</p>
<h3>You may also be interested in:</h3>
<p><a href="http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-forms-regions/">Advanced Outlook Regions for Outlook forms and views</a><br />
<a href="http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-explorer-inspector-regions/">Advanced Outlook Regions for Explorer and Inspector windows</a><br />
<a href="http://www.add-in-express.com/creating-addins-blog/2009/04/22/outlook-regions-read-compose/">Advanced Outlook Regions: read and compose mode</a><br />
<a href="http://www.add-in-express.com/creating-addins-blog/2009/04/29/outlook-forms-minimized-restored/">Advanced Outlook Regions: minimized, expanded, hidden</a></p>
<h3>Available downloads:</h3>
<p><a href="http://www.add-in-express.com/files/howtos/blog/adx-drag-drop-minimized-cs.zip">C# sample Outlook and Word add-in for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-drag-drop-minimized-vb.zip">VB.NET sample Outlook and Word add-in for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-drag-drop-minimized-delphi.zip">Delphi 7 sample Outlook and Word add-in</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/08/21/drag-drop-minimized-outlook-region/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo: Get an IE add-on to interact with a standalone application</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/06/26/ie-addon-interact-standalone-application/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/06/26/ie-addon-interact-standalone-application/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 18:02:32 +0000</pubDate>
		<dc:creator>Dmitry Kostochko</dc:creator>
				<category><![CDATA[HowTo samples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IE add-ons]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=842</guid>
		<description><![CDATA[In general, you can have IE add-ons interact with standalone applications by using Windows messages and the Shared (static in C#) GetModulesByTypeName method of the AddinExpress.IE.ADXIEModule class. There is just one limitation: both processes (IE with your add-on and standalone application) must be running in the same Integrity Level.]]></description>
			<content:encoded><![CDATA[<p>In general, you can have IE add-ons interact with standalone applications by using Windows messages and the <strong>Shared</strong> (<strong>static</strong> in C#) <em>GetModulesByTypeName</em> method of the <em>AddinExpress.IE.ADXIEModule</em> class. There is just one limitation: both processes (IE with your add-on and standalone application) must be running in the same Integrity Level.</p>
<p>Ok, so here we go now. In the IEModule class of your IE add-on, you need the following declarations:</p>
<pre class="SrcCode"><code class="vb">
Private ADDON_TO_MYAPP_MessageId As IntPtr
Private MSG_ADDON_TO_MYAPP As String = "ADDON_TO_MYAPP"
 _
Public Shared Function RegisterWindowMessage( _
    ByVal lpString As [String]) As IntPtr
End Function
 _
Public Shared Function FindWindow( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As IntPtr
End Function
 _
Public Shared Function PostMessage( _
    ByVal hwnd As IntPtr, _
    ByVal wMsg As IntPtr, ByVal wParam As Int32, _
    ByVal lParam As Int32) As IntPtr
End Function</code></pre>
<p>Then the OnConnect, OnDisconnect, DocumentComplete event handlers:</p>
<pre class="SrcCode"><code class="vb">
Private Sub IEModule_OnConnect( _
    ByVal sender As System.Object, _
    ByVal threadId As System.Int32) _
    Handles MyBase.OnConnect

    Me.ADDON_TO_MYAPP_MessageId = _
        RegisterWindowMessage(MSG_ADDON_TO_MYAPP)
    SendMessageToMyApp(0)
End Sub

Private Sub IEModule_OnDisconnect( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.OnDisconnect

    SendMessageToMyApp(1000)
End Sub

Private Sub IEModule_DocumentComplete( _
    ByVal pDisp As System.Object, _
    ByVal url As System.String) _
    Handles MyBase.DocumentComplete

    SendMessageToMyApp(0)
End Sub</code></pre>
<p>And three methods: SendMessageToMyApp is used to notify your standalone application about events, such as opening/closing a tab and web-page loading. The other two are called from the application:</p>
<pre class="SrcCode"><code class="vb">
Private Sub SendMessageToMyApp(ByVal delay As Integer)
    Dim hwnd As IntPtr = FindWindow(Nothing, "My Application")
    If hwnd &lt;&gt; IntPtr.Zero Then
        PostMessage(hwnd, Me.ADDON_TO_MYAPP_MessageId, delay, 0)
    End If
End Sub

Public Function GetCurrentTitle() As String
    Try
        Dim text As String = Me.HTMLDocument.title
        If [String].IsNullOrEmpty(text) Then
            text = "Blank Page"
        End If
        Return text
    Catch
    End Try
    Return [String].Empty
End Function

Public Sub NavigateTo(ByVal url As String)
    Try
        Dim dummy As Object = Type.Missing
        Me.IEApp.Navigate(url, dummy, dummy, dummy, dummy)
    Catch err As Exception
        MessageBox.Show(err.Message, Me.ModuleName, _
            MessageBoxButtons.OK, MessageBoxIcon.[Error])
    End Try
End Sub</code></pre>
<p>And now the key piece of the application. Using the <em>GetModulesByTypeName</em> method, you can get a list of instances of your IEModule classes and use their methods and properties:</p>
<pre class="SrcCode"><code class="vb">
Private Sub RefreshItems()
    Dim [module] As ADX_IE_Addon_And_WinApp_VB.IEModule
    comboBox1.BeginUpdate()
    Try
        remoteModules.Clear()
        comboBox1.Items.Clear()
        Dim modules As ArrayList = _
            AddinExpress.IE.ADXIEModule.GetModulesByTypeName( _
                "ADX_IE_Addon_And_WinApp_VB.IEModule")
        If modules.Count &gt; 0 Then
            For i As Integer = 0 To modules.Count - 1
                [module] = TryCast(modules(i), _
                    ADX_IE_Addon_And_WinApp_VB.IEModule)
                If [module] IsNot Nothing Then
                    remoteModules.Add([module])
                    comboBox1.Items.Add( _
                        [module].GetCurrentTitle())
                End If
            Next
        End If
        If comboBox1.Items.Count &gt; 0 Then
            comboBox1.SelectedIndex = 0
        Else
            Application.[Exit]()
        End If
    Catch err As Exception
        MessageBox.Show(err.Message, Me.Text, _
            MessageBoxButtons.OK, MessageBoxIcon.[Error])
    Finally
        comboBox1.EndUpdate()
    End Try
End Sub</code></pre>
<p>That’s all with it.</p>
<h3>You may also be interested in:</h3>
<p><a href="http://msdn.microsoft.com/en-us/library/bb250462(VS.85).aspx" target=_blank>Understanding and Working in Protected Mode Internet Explorer</a><br />
<a href="http://www.add-in-express.com/programming-internet-explorer/developing-addons.php">How to develop an add-on for IE6, IE7 and IE8</a><br />
<a href="http://www.add-in-express.com/docs/internet-explorer-toolbars.php">How to add a custom button to IE toolbar</a><br />
<a href="http://www.add-in-express.com/docs/internet-explorer-bars.php">How to create an Explorer bar and context menu</a></p>
<h3>Available downloads:</h3>
<p>This sample add-in was developed using <strong><a href="http://www.add-in-express.com/programming-internet-explorer/">Add-in Express 2009 for Internet Explorer and .net</a></strong></p>
<p><a href="http://www.add-in-express.com/files/howtos/blog/adx-ie-addon-and-win-app-cs.zip">C# sample IE add-on for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-ie-addon-and-win-app-vb.zip">VB.NET sample IE add-on for VS 2005</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/06/26/ie-addon-interact-standalone-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo: Synchronize settings of an IE plug-in</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/06/19/internet-explorer-plugin-settings-synchronize/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/06/19/internet-explorer-plugin-settings-synchronize/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 17:13:13 +0000</pubDate>
		<dc:creator>Dmitry Kostochko</dc:creator>
				<category><![CDATA[HowTo samples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IE add-ons]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=831</guid>
		<description><![CDATA[Nearly every software has some settings. An Internet Explorer plug-in is not an exception. The IE plug-in settings can be stored either in a file or in a registry branch, all is simple and transparent about this. But how to ensure the settings synchronization for all active instances of the IE plug-in in all running Internet Explorer processes?]]></description>
			<content:encoded><![CDATA[<p>Nearly every software program has some settings. An Internet Explorer plug-in is not an exception. The IE add-on settings can be stored either in a file or in a registry branch, all is simple and transparent about this. But how to ensure the settings synchronization for all active instances of the IE plug-in in all running Internet Explorer processes? By using the <em>AddinExpress.IE.ADXIESharedMemory</em> class.</p>
<p>Well, here goes! Let&#8217;s create a new IE plug-in project using the &#8220;ADX IE Bar&#8221; wizard, populate our IEBarModule with a group box that has 3 radio buttons, add a couple of checkboxes, a combo box and text box. Ergo, we need to store and synchronize 5 values, Integer as index for RadioButtons, two Boolean values as CheckBox states, another Integer as index for ComboBox and String for TextBox. Now, add to the project your own class, a descendent of <em>ADXIESharedMemory</em>, by using &#8220;ADX IE Shared Data&#8221; wizard and modify the GlobalData class, which is present in every IE plug-in project.</p>
<p>Here is a list of private variables needed:</p>
<pre class="SrcCode"><code class="vb">
Private lastOutputPath As String
Private optionPageData As MySharedData

Private Const FILE_LOCKED As Integer = 0
Private Const RADIO_OPTION As Integer = 1
Private Const CHECK_OPTION_1 As Integer = 2
Private Const CHECK_OPTION_2 As Integer = 3
Private Const LIST_OPTION As Integer = 4
Private Const STRING_OPTION As Integer = 5</code></pre>
<p>Modified constructor:</p>
<pre class="SrcCode"><code class="vb">
Public Sub New()
    MyBase.New()
    'System.Diagnostics.Debugger.Break()
    Dim outputPath As String = _
        Path.Combine(Environment.GetFolderPath( _
        Environment.SpecialFolder.InternetCache), "Low")
    outputPath = Path.Combine(outputPath, "MyIEOptionPage")
    If Not Directory.Exists(outputPath) Then
        Directory.CreateDirectory(outputPath)
    End If
    Me.lastOutputPath = outputPath
    Me.optionPageData = New MySharedData( _
        "MyIEOptionPage", 512, 10)

    Me.optionPageData(FILE_LOCKED) = 0
    Me.optionPageData(RADIO_OPTION) = 0
    Me.optionPageData(CHECK_OPTION_1) = False
    Me.optionPageData(CHECK_OPTION_2) = False
    Me.optionPageData(LIST_OPTION) = 0
    Me.optionPageData(STRING_OPTION) = "Default"
End Sub</code></pre>
<p>Added methods:</p>
<pre class="SrcCode"><code class="vb">
Public Sub LoadOptions()
    If CInt(Me.optionPageData(FILE_LOCKED)) = 0 Then
        Me.optionPageData(FILE_LOCKED) = 1
        Try
            Dim outputFile As String = _
                Path.Combine(lastOutputPath, "myoptions.cfg")
            If File.Exists(outputFile) Then
                Using sr As New StreamReader(outputFile)
                    Dim line As String
                    line = sr.ReadLine()
                    Me.optionPageData(RADIO_OPTION) = _
                      Convert.ToInt32(line.Trim())
                    line = sr.ReadLine()
                    Me.optionPageData(CHECK_OPTION_1) = _
                      Convert.ToBoolean(line.Trim())
                    line = sr.ReadLine()
                    Me.optionPageData(CHECK_OPTION_2) = _
                      Convert.ToBoolean(line.Trim())
                    line = sr.ReadLine()
                    Me.optionPageData(LIST_OPTION) = _
                      Convert.ToInt32(line.Trim())
                    line = sr.ReadLine()
                    Me.optionPageData(STRING_OPTION) = _
                      line.Trim()
                End Using
            End If
        Finally
            Me.optionPageData(FILE_LOCKED) = 0
        End Try
    End If
End Sub

Private Sub SaveOptions()
    If CInt(Me.optionPageData(FILE_LOCKED)) = 0 Then
        Me.optionPageData(FILE_LOCKED) = 1
        Try
            Dim outputFile As String = _
                Path.Combine(lastOutputPath, "myoptions.cfg")
            Using sw As New StreamWriter(outputFile, False)
                sw.Write(Me.optionPageData(RADIO_OPTION))
                sw.Write(sw.NewLine)
                sw.Write(Me.optionPageData(CHECK_OPTION_1))
                sw.Write(sw.NewLine)
                sw.Write(Me.optionPageData(CHECK_OPTION_2))
                sw.Write(sw.NewLine)
                sw.Write(Me.optionPageData(LIST_OPTION))
                sw.Write(sw.NewLine)
                sw.Write(Me.optionPageData(STRING_OPTION))
            End Using
        Finally
            Me.optionPageData(FILE_LOCKED) = 0
        End Try
    End If
End Sub

Public Sub UpdateOptions(ByVal [module] As IEBarModule)
    SyncLock Instance
        Me.optionPageData(RADIO_OPTION) = [module].RadioOptions
        Me.optionPageData(CHECK_OPTION_1) = [module].CheckOption1
        Me.optionPageData(CHECK_OPTION_2) = [module].CheckOption2
        Me.optionPageData(LIST_OPTION) = [module].ListOption
        Me.optionPageData(STRING_OPTION) = [module].StringOption
        SaveOptions()
    End SyncLock
End Sub

Public Sub RefreshOptions(ByVal [module] As IEBarModule)
    SyncLock Instance
        [module].RadioOptions = _
          CInt(Me.optionPageData(RADIO_OPTION))
        [module].CheckOption1 = _
          CBool(Me.optionPageData(CHECK_OPTION_1))
        [module].CheckOption2 = _
          CBool(Me.optionPageData(CHECK_OPTION_2))
        [module].ListOption = _
          CInt(Me.optionPageData(LIST_OPTION))
        [module].StringOption = _
          DirectCast(Me.optionPageData(STRING_OPTION), String)
    End SyncLock
End Sub

Public Sub CloseOptions()
    SyncLock Instance
        If Me.optionPageData IsNot Nothing Then
            Try
                SaveOptions()
            Finally
                Me.optionPageData.Dispose()
                Me.optionPageData = Nothing
            End Try
        End If
    End SyncLock
End Sub</code></pre>
<p>Now let&#8217;s go back to IEBarModule and add Load, OnConnect, OnDisconnect, OnSendMessage and two button Click event handlers (one to apply settings, and another to cancel them):</p>
<pre class="SrcCode"><code class="vb">
Private startMode As Boolean = True
Private Const WM_UPDATE_OPTIONS As Integer = (&amp;H400 + 3000)

Private Sub IEBarModule_Load( _
    ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles MyBase.Load

    Try
        GlobalData.Instance.LoadOptions()
    Catch err As Exception
        MessageBox.Show(err.Message, Me.Title, _
          MessageBoxButtons.OK, MessageBoxIcon.[Error])
    End Try
End Sub

Private Sub IEBarModule_OnConnect( _
    ByVal sender As System.Object, _
    ByVal threadId As System.Int32) Handles MyBase.OnConnect

    comboBox1.SelectedIndex = 0
    SendMessageToAll(WM_UPDATE_OPTIONS, IntPtr.Zero, IntPtr.Zero)
    startMode = False
End Sub

Private Sub IEBarModule_OnDisconnect( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.OnDisconnect

    Try
        GlobalData.Instance.CloseOptions()
    Catch err As Exception
        MessageBox.Show(err.Message, Me.Title, _
          MessageBoxButtons.OK, MessageBoxIcon.[Error])
    End Try
End Sub

Private Sub IEBarModule_OnSendMessage( _
    ByVal e As AddinExpress.IE.ADXIESendMessageEventArgs) _
    Handles MyBase.OnSendMessage

    Select Case e.Message
        Case WM_UPDATE_OPTIONS
            If True Then
                startMode = True
                Try
                    GlobalData.Instance.RefreshOptions(Me)
                Finally
                    startMode = False
                End Try
            End If
            Exit Select
    End Select
End Sub

Private Sub buttonApply_Click( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles buttonApply.Click

    Try
        GlobalData.Instance.UpdateOptions(Me)
        SendMessageToAll(WM_UPDATE_OPTIONS, IntPtr.Zero, _
            IntPtr.Zero)
    Finally
        buttonApply.Enabled = False
        buttonCancel.Enabled = False
    End Try
End Sub

Private Sub buttonCancel_Click( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles buttonCancel.Click

    Try
        GlobalData.Instance.RefreshOptions(Me)
    Finally
        buttonApply.Enabled = False
        buttonCancel.Enabled = False
    End Try
End Sub</code></pre>
<p>So, now we have all the settings stored in the myoptions.cfg file. Once the settings are changed, all active instances of the IE plug-in in all running Internet Explorer processes learn the fact and get to know their new values.</p>
<p>That’s all for today.</p>
<h3>You may also be interested in:</h3>
<p><a href="http://www.add-in-express.com/programming-internet-explorer/developing-addons.php">How to develop an add-on for IE6, IE7 and IE8</a><br />
<a href="http://www.add-in-express.com/docs/internet-explorer-toolbars.php">How to create a custom button for IE toolbar</a><br />
<a href="http://www.add-in-express.com/docs/internet-explorer-bars.php">How to build an Explorer bar and context menu</a></p>
<h3>Available downloads:</h3>
<p>This sample add-in was developed using <strong><a href="http://www.add-in-express.com/programming-internet-explorer/">Add-in Express 2009 for Internet Explorer and .net</a></strong></p>
<p><a href="http://www.add-in-express.com/files/howtos/blog/adx-ie-shared-memory-cs.zip">C# sample IE plug-in for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-ie-shared-memory-vb.zip">VB.NET sample IE plug-in for VS 2005</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/06/19/internet-explorer-plugin-settings-synchronize/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HowTo: Deal with Protected Mode API in Internet Explorer 7 and IE8</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/06/12/internet-explorer-protected-mode-api/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/06/12/internet-explorer-protected-mode-api/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 18:08:36 +0000</pubDate>
		<dc:creator>Dmitry Kostochko</dc:creator>
				<category><![CDATA[HowTo samples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IE add-ons]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=818</guid>
		<description><![CDATA[The Protected Mode feature was introduced in Internet Explorer 7 and continues to exist in Internet Explorer 8. Nearly at the same time when the Protected Mode feature appeared Microsoft introduced Protected Mode API for developers to use this feature. All API functions are implemented in the Add-in Express for Internet Explorer and .net product and today we are going to look into their capabilities...]]></description>
			<content:encoded><![CDATA[<p>The Protected Mode feature was introduced in Internet Explorer 7 and continues to exist in Internet Explorer 8. Nearly at the same time when the Protected Mode feature appeared, Microsoft introduced the <a href="http://msdn.microsoft.com/en-us/library/ms537319(VS.85).aspx" target="_blank">Protected Mode API</a> for developers to use this feature.</p>
<p>All API functions are implemented in the <a href="http://www.add-in-express.com/programming-internet-explorer/">Add-in Express for Internet Explorer and .net</a> product and today we are going to look into their capabilities.</p>
<p>You can create an instance of the <em>AddinExpress.IE.ADXIEProtectedModeAPI</em> class and check out the Protection Mode state using the <em>OnCreate</em> event handler:</p>
<pre class="SrcCode"><code class="vb">
Private Sub IEToolBarModule_OnConnect( _
    ByVal sender As System.Object, _
    ByVal threadId As System.Int32) _
    Handles MyBase.OnConnect

    Try
        Me.pAPI = New AddinExpress.IE.ADXIEProtectedModeAPI()
        If Me.pAPI.IsProtectedModeOn() Then
            Me.label1.Text = "Protected Mode: On"
        Else
            Me.label1.Text = "Protected Mode: Off"
        End If
    Catch err As Exception
        MessageBox.Show(err.Message, Me.MenuText, _
          MessageBoxButtons.OK, MessageBoxIcon.[Error])
    End Try
End Sub
</code></pre>
<p>Then you can use the <em>ADXIEProtectedModeAPI</em> methods in your code. In the code below, the <em>ShowSaveFileDialog</em>, <em>GetWriteableFolderPath</em> and <em>SaveFile</em> methods are used for saving a file into a location specified by the end-user:</p>
<pre class="SrcCode"><code class="vb">
Private Sub buttonSave_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles buttonSave.Click

    Dim tmpFilePath As String = String.Empty
    Try
        If Me.pAPI IsNot Nothing Then
            Dim state As Integer = 0
            Dim fileName As String
            fileName = Me.pAPI.ShowSaveFileDialog( _
                Me.TabWindowHandle, _
                "Log.txt", _
                Nothing, _
                "Text files|*.txt|All files|*.*|", "txt", _
                1, _
                ADXIEOpenFileNameFlags.ofnEnableSizing Or _
                ADXIEOpenFileNameFlags.ofnHideReadOnly Or _
                ADXIEOpenFileNameFlags.ofnPathMustExist Or _
                ADXIEOpenFileNameFlags.ofnOverWritePrompt, _
                state)
            If state = 0 Then Exit Sub
            Try
                tmpFilePath = Me.pAPI.GetWriteableFolderPath()
                tmpFilePath = Path.Combine(tmpFilePath, _
                  "IEProtectedModeAPI")
                If Not Directory.Exists(tmpFilePath) Then
                    Directory.CreateDirectory(tmpFilePath)
                End If
                tmpFilePath = Path.Combine(tmpFilePath, "log.txt")

                Using sw As New StreamWriter(tmpFilePath, False)
                    sw.WriteLine("IEProtectedModeAPI Example")
                    sw.WriteLine("--------------------------")
                    sw.WriteLine("This is just a test.")
                End Using

                If Not File.Exists(tmpFilePath) Then
                    Throw New FileNotFoundException( _
                      "The log file doesn't exist.")
                End If

                Me.pAPI.SaveFile(state, tmpFilePath)
                MessageBox.Show(Me, _
                  "The file has been successfully saved.", _
                  Me.MenuText, MessageBoxButtons.OK, _
                  MessageBoxIcon.Information)
            Catch
                Me.pAPI.CancelSaveFile(state)
                Throw
            End Try
        End If
    Catch err As Exception
        MessageBox.Show(Me, err.Message, Me.MenuText, _
            MessageBoxButtons.OK, MessageBoxIcon.[Error])
    Finally
        If tmpFilePath &lt;&gt; String.Empty Then
            If File.Exists(tmpFilePath) Then
                File.Delete(tmpFilePath)
            End If
        End If
    End Try
End Sub
</code></pre>
<p>Now you can save your data not only to a special pre-determined location that you can obtain by using the <em>GetWritableFolderPath</em> function, but to any location specified by the end-user. That’s all for today.</p>
<h3>You may also be interested in:</h3>
<p><a href="http://www.add-in-express.com/programming-internet-explorer/developing-addons.php">How to create an add-on for IE6, IE7 and IE8</a><br />
<a href="http://www.add-in-express.com/docs/internet-explorer-toolbars.php">How to develop an IE toolbar with custom buttons</a><br />
<a href="http://www.add-in-express.com/programming-internet-explorer/project-template.php">Building IE browser helper objects</a></p>
<h3>Available downloads:</h3>
<p>This sample add-in was developed using <strong><a href="http://www.add-in-express.com/programming-internet-explorer/">Add-in Express 2009 for Internet Explorer and .net</a></strong></p>
<p><a href="http://www.add-in-express.com/files/howtos/blog/adx-ie-protected-mode-api-cs.zip">C# sample IE plug-in for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-ie-protected-mode-api-vb.zip">VB.NET sample IE plug-in for VS 2005</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/06/12/internet-explorer-protected-mode-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo: Use MS Word Object Model to get synonyms and antonyms lists programmatically</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/05/23/word-synonyms-antonyms-object-model/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/05/23/word-synonyms-antonyms-object-model/#comments</comments>
		<pubDate>Sat, 23 May 2009 14:37:13 +0000</pubDate>
		<dc:creator>Dmitry Kostochko</dc:creator>
				<category><![CDATA[HowTo samples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=794</guid>
		<description><![CDATA[In one of my previous HowTo samples I showed you how to use the Microsoft Word Object Model capabilities for spell checking. Today we will look at one more ability of Microsoft Word, namely the capabilities of its dictionary, more specifically synonyms and antonyms. We will need the SynonymInfo object and SynonymList and AntonymList properties...]]></description>
			<content:encoded><![CDATA[<p>In one of my previous HowTo samples I showed you how to use the <a href="http://www.add-in-express.com/creating-addins-blog/2009/03/27/word-spellcheck-object-model/">Microsoft Word Object Model capabilities for spell checking</a>. Today we will look at one more ability of MS Word, namely the capabilities of its dictionary, more specifically synonyms and antonyms. We will need the <a href="http://msdn.microsoft.com/en-us/library/bb178951.aspx" target="_blank">SynonymInfo</a> object and <a href="http://msdn.microsoft.com/en-us/library/bb211278.aspx" target="_blank">SynonymList</a> and <a href="http://msdn.microsoft.com/en-us/library/bb211272.aspx" target="_blank">AntonymList</a> properties.</p>
<p>Using the code bellow, we can promptly and easily get a list of synonyms for a given word, i.e. a word on which the cursor is placed:</p>
<pre class="SrcCode"><code class="vb">
Private Sub AdxCommandBarButton1_Click( _
    ByVal sender As System.Object) _
    Handles AdxCommandBarButton1.Click, ShortcutSynonym.Action

    Dim frm As New Form1()
    frm.ListBox1.Items.Clear()
    frm.Text = "Synonym list"
    frm.Label1.Text = "Select synonym:"

    Dim selection As Word.Selection = WordApp().Selection
    If selection IsNot Nothing Then
        Try
            Dim wordText As String = selection.Words.Last.Text
            Dim objLanguage As Object = Word.WdLanguageID.wdEnglishUS
            Dim info As Word.SynonymInfo
            info = WordApp().SynonymInfo(wordText, objLanguage)
            If info IsNot Nothing Then
                Try
                    If info.MeaningCount &gt; 0 Then
                        Dim duplicate As Boolean
                        For Each meaning As String In _
                            DirectCast(info.MeaningList, System.Array)

                            Dim objMeaning As Object = meaning
                            Dim synonyms As System.Array
                            synonyms = DirectCast( _
                                info.SynonymList(objMeaning), _
                                System.Array)
                            For Each synonym As String In synonyms
                                duplicate = False
                                Dim list As String
                                For Each list In frm.ListBox1.Items
                                    If list = synonym Then
                                        duplicate = True
                                        Exit For
                                    End If
                                Next
                                If Not duplicate Then
                                    frm.ListBox1.Items.Add(synonym)
                                End If
                            Next
                        Next
                        frm.ListBox1.SelectedIndex = 0
                        If frm.ShowDialog() = DialogResult.OK Then
                            ReplaceWord( _
                                selection, _
                                wordText.Trim().Length, _
                                frm.ListBox1.Text)
                        End If
                    Else
                        MessageBox.Show( _
                            "There are no synonyms for this word.")
                    End If
                Finally
                    Marshal.ReleaseComObject(info)
                End Try
            End If
        Finally
            Marshal.ReleaseComObject(selection)
        End Try
    End If
    frm.Dispose()
End Sub</code></pre>
<p>The code that allows getting the antonyms list is more compact and easier. You can get it by downloading the VB.NET and C# samples below.<br />
Please keep in mind that you can get the synonym and antonym lists not only via a COM add-in but from a standalone application as well by using the MS Word Object Model capabilities.</p>
<h3>You may also be interested in:</h3>
<p><a href="http://www.add-in-express.com/docs/net-first-com-addin.php">How to develop a COM add-in for Microsoft Word step-by-step</a></p>
<h3>Available downloads:</h3>
<p>This sample add-in was developed using<br />
<strong><a href="http://www.add-in-express.com/add-in-net/">Add-in Express 2008 for Microsoft Office and .net</a></strong></p>
<p><a href="http://www.add-in-express.com/files/howtos/blog/adx-wd-synonym-replacement-cs.zip">C# sample Word add-in for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-wd-synonym-replacement-vb.zip">VB.NET sample Word add-in for VS 2005</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/05/23/word-synonyms-antonyms-object-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo: Avoid limitations of Microsoft Outlook ItemAdd event</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/05/15/outlook-itemadd-event/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/05/15/outlook-itemadd-event/#comments</comments>
		<pubDate>Fri, 15 May 2009 16:59:18 +0000</pubDate>
		<dc:creator>Dmitry Kostochko</dc:creator>
				<category><![CDATA[HowTo samples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[COM add-ins]]></category>
		<category><![CDATA[MAPI]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=784</guid>
		<description><![CDATA[The description of the ItemAdd event is laconic and compact - "Occurs when one or more items are added to the specified collection. This event does not run when a large number of items are added to the folder at once." But what is really implied by the words "a large number of items"?]]></description>
			<content:encoded><![CDATA[<p>The description of the <a href="http://msdn.microsoft.com/en-us/library/bb220152.aspx">ItemAdd event</a> is laconic and compact &#8211; &#8220;Occurs when one or more items are added to the specified collection. This event does not run when a large number of items are added to the folder at once.&#8221; But what is really implied by the words &#8220;a large number of items&#8221;?</p>
<p>Our tests show that in Outlook 2000, 2002 and 2003 this event is not fired if more than 16 elements are dragged. Imagine, only 16! Outlook 2007 with SP2 is more stable in this regard, the <em>ItemAdd</em> event stops firing when more than 512 elements are dragged simultaneously. How can you get all the moved items? You need to use the Extended MAPI <a href="http://msdn.microsoft.com/en-us/library/cc842238.aspx">IMsgStore::Advise</a> method and implement the <a href="http://msdn.microsoft.com/en-us/library/cc815622.aspx">IMAPIAdviseSink::OnNotify</a> method.</p>
<p>All this has already been implemented in our <a href="http://www.add-in-express.com/products/mapi-store-events.php">MAPI Store Accessor</a> and works just fine (BTW, it is a free tool and you can <a href="http://www.add-in-express.com/downloads/mapi-store-events.php">download</a> it right now). In this particular case, it is the OnObjectMoved event that interests us most:</p>
<pre class="SrcCode"><code class="vb">
Private Sub adxmapiStoreAccessor_OnObjectMoved( _
    ByVal sender As System.Object, _
    ByVal e As AddinExpress.MAPI.ADXMAPIObjectNotificationEventArgs) _
    Handles adxmapiStoreAccessor.OnObjectMoved

    Dim folder As AddinExpress.MAPI.Folder = _
        adxmapiStoreAccessor.GetMapiFolder(itemsEvents.FolderObj)
    If folder IsNot Nothing Then
        Dim folderId As Object
        folderId = folder.GetProperty( _
            AddinExpress.MAPI.ADXMAPIPropertyTag._PR_ENTRYID)
        folder.Dispose()
        If e.ParentId.ToString() = _
            AddinExpress.MAPI.EntryId.ConvertToString( _
            CType(folderId, Byte())) Then
            Dim ns As Outlook._NameSpace
            ns = OutlookApp.GetNamespace("MAPI")
            If ns IsNot Nothing Then
                Try
                    Dim mail As Outlook.MailItem
                    mail = TryCast( _
                        ns.GetItemFromID(e.EntryId.ToString(), _
                        Type.Missing), Outlook.MailItem)
                    If mail IsNot Nothing Then
                        Try
                            AddEventToLog( _
                                " Object moved. Subject = " + _
                                mail.Subject)
                        Finally
                            Marshal.ReleaseComObject(mail)
                        End Try
                    End If
                Finally
                    Marshal.ReleaseComObject(ns)
                End Try
            End If
        End If
    End If
End Sub</code></pre>
<p>MAPI store events have 2 specificities related to <strong>MS Exchange-based</strong> stores:</p>
<ul class="list">
<li>Events are raised asynchronously, which means that it could be a significant time interval since the items were dragged before the event was triggered.</li>
<li>The Public Folders store doesn&#8217;t support events at all.</li>
</ul>
<p>Well, thanks for reading. Hope somebody finds it useful.</p>
<h3>Available downloads:</h3>
<p>This sample add-in was developed using <strong><a href="http://www.add-in-express.com/add-in-net/">Add-in Express 2008 for Microsoft Office and .net</a></strong></p>
<p><a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-item-add-cs.zip">C# sample Outlook add-in for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-item-add-vb.zip">VB.NET sample Outlook add-in for VS 2005</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/05/15/outlook-itemadd-event/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HowTo: Convert Exchange-based email address into SMTP email address</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/05/08/outlook-exchange-email-address-smtp/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/05/08/outlook-exchange-email-address-smtp/#comments</comments>
		<pubDate>Fri, 08 May 2009 16:54:09 +0000</pubDate>
		<dc:creator>Dmitry Kostochko</dc:creator>
				<category><![CDATA[HowTo samples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[COM add-ins]]></category>
		<category><![CDATA[MAPI]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=753</guid>
		<description><![CDATA[It would be true to say "get" rather than "convert". There could be only one right way – to use Extended MAPI. Another method is described in the MSDN article: How to retrieve alternate e-mail addresses by using CDO, but we will not see into this approach, because CDO is optional in Outlook 2003 and is absent completely in Outlook 2007.]]></description>
			<content:encoded><![CDATA[<p>It would be true to say &#8220;get&#8221; rather than &#8220;convert&#8221;. There could be only one right way &#8211; to use Extended MAPI. Another method is described in the MSDN article: <a href="http://support.microsoft.com/kb/196507/">How to retrieve alternate e-mail addresses by using CDO</a>, but we will not see into this approach, because CDO is optional in Outlook 2003 and is absent completely in Outlook 2007.</p>
<p>So, Microsoft Exchange Server can operate with email address types such as Exchange, SMTP, X.400, Microsoft Mail, etc. By default, the <em>Address</em> property of the <em>Mail.Recipient</em> object returns just an Exchange type address, for example this one:</p>
<p>/O=ORGANIZATION_NAME /OU=EXCHANGE_GROUP /CN=RECIPIENTS /CN=USER_NAME</p>
<p>To get other address types, we need to find the recipient in the Outlook address book by using the <em>IAddrBook.ResolveName</em> method, then reach the <em>IMailUser</em> interface with the <em>IAddrBook.OpenEntry</em> method and get the <em>PR_EMS_AB_PROXY_ADDRESSES</em> property. The code below gets the <em>Address</em> property from <em>NameSpace.CurrentUser.AddressEntry</em>, checks the address type and obtains the SMTP address if it is of the Exchange type:</p>
<pre class="SrcCode"><code class="vb">
Private Sub CommandBarButton1_Click(ByVal sender As System.Object) _
    Handles CommandBarButton1.Click

    ' Outlook Explorer button
    Dim ns As Outlook._NameSpace = OutlookApp.Session
    If ns IsNot Nothing Then
        Try
            Dim currentUser As Outlook.Recipient = ns.CurrentUser
            If currentUser IsNot Nothing Then
                Try
                    Dim entry As Outlook.AddressEntry = _
                        currentUser.AddressEntry
                    If entry IsNot Nothing Then
                        Try
                            Dim smtpAddress As String = String.Empty
                            ' Exchange address
                            If (entry.Type = "EX") Then
                                smtpAddress = GetSMTPAddress( _
                                    entry.Address)
                            Else
                                smtpAddress = entry.Address
                            End If
                            MessageBox.Show("SMTP Address:" + _
                                Environment.NewLine + _
                                smtpAddress)
                        Finally
                            Marshal.ReleaseComObject(entry)
                        End Try
                    End If
                Finally
                    Marshal.ReleaseComObject(currentUser)
                End Try
            End If
        Finally
            Marshal.ReleaseComObject(ns)
        End Try
    End If
End Sub</code></pre>
<p>I will not publish the whole code of the <em>GetSMTPAddress</em> method right here, because it is rather huge. You can download VB.NET and C# samples with source code, including the declaration of Extended MAPI interfaces, types, tags and properties via the links below.</p>
<p>That&#8217;s all for now, have a nice weekend!</p>
<h3>Available downloads:</h3>
<p>The sample add-ins below were developed on<strong> </strong><a href="http://www.add-in-express.com/add-in-net/"><strong>Add-in Express 2009 for Office and .net</strong></a></p>
<p><a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-smtp-address-cs.zip">C# sample Outlook add-in for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-smtp-address-vb.zip">VB.NET sample Outlook add-in for VS 2005</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/05/08/outlook-exchange-email-address-smtp/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>HowTo: Support Office 2007 color schemes in your custom forms and task panes</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/05/01/office-color-schemes/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/05/01/office-color-schemes/#comments</comments>
		<pubDate>Fri, 01 May 2009 17:46:37 +0000</pubDate>
		<dc:creator>Dmitry Kostochko</dc:creator>
				<category><![CDATA[HowTo samples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[COM add-ins]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[Outlook regions]]></category>
		<category><![CDATA[task panes]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=749</guid>
		<description><![CDATA[In Office 2007 there are 3 available color schemes – Black, Blue and Silver. The background of controls in command bars and ribbon tabs is changed by Office automatically. Do you want to try changing the background of your Outlook forms and Excel task panes when the MS Office color scheme is changed?]]></description>
			<content:encoded><![CDATA[<p>In Office 2007 there are 3 available color schemes &#8211; <em>Black</em>, <em>Blue</em> and <em>Silver</em>. The background of controls in command bars and ribbon tabs is changed by Microsoft Office automatically. Do you want to try changing the background of your Outlook forms and Excel task panes when the MS Office color scheme is changed?</p>
<p>Add-in Express has all needed stuff except for the color to fill the background. Firstly, we&#8217;ll need the <em>OfficeColorSchemeChanged</em> event handler in which we forcibly change the background of all our custom forms:</p>
<pre class="SrcCode"><code class="vb">
Private Sub AddinModule_OfficeColorSchemeChanged( _
    ByVal sender As System.Object, _
    ByVal theme As AddinExpress.MSO.OfficeColorScheme) _
    Handles MyBase.OfficeColorSchemeChanged

    ' Excel task pane
    If Me.HostType = AddinExpress.MSO.ADXOfficeHostApp.ohaExcel Then
        Dim ExcelPane As ADXExcelTaskPane1
        ExcelPane = CType( _
            ExcelTaskPanesCollectionItem.TaskPaneInstance, _
            ADXExcelTaskPane1)
        ExcelPane.DoPaint(theme)
    End If
    ' Outlook forms
    If Me.HostType = AddinExpress.MSO.ADXOfficeHostApp.ohaOutlook Then
        Dim OutlookForm As ADXOlForm1
        Dim I As Integer
        For I = 0 To OlFormsCollectionItem.FormInstanceCount - 1
            OutlookForm = CType( _
                OlFormsCollectionItem.FormInstances(I), _
                ADXOlForm1)
            OutlookForm.DoPaint(theme)
        Next
    End If
End Sub</code></pre>
<p>Secondly, your custom form, or a task pane, needs to be able to paint its background before it shows up:</p>
<pre class="SrcCode"><code class="vb">
Private Sub ADXExcelTaskPane1_ADXBeforeTaskPaneShow( _
    ByVal sender As System.Object, _
    ByVal e As AddinExpress.XL.ADXBeforeTaskPaneShowEventArgs) _
    Handles MyBase.ADXBeforeTaskPaneShow

    DoPaint(CType (AddinModule, AddinModule).OfficeColorScheme)
End Sub

Private Sub ADXOlForm1_ADXBeforeFormShow() Handles _
    MyBase.ADXBeforeFormShow

    DoPaint(CType(AddinModule, AddinModule).OfficeColorScheme)
End Sub</code></pre>
<p>And here is the key point – colors:</p>
<ul class="list">
<li>Black &#8211; &amp;HEBEBEB (0xEBEBEB)</li>
<li>Blue &#8211; &amp;HD5E4F2 (0xD5E4F2)</li>
<li>Silver &#8211; &amp;HEEEEF4 (0xEEEEF4)</li>
</ul>
<pre class="SrcCode"><code class="vb">
Public Sub DoPaint(ByVal theme As _
    AddinExpress.MSO.OfficeColorScheme)

    Select Case theme
        Case AddinExpress.MSO.OfficeColorScheme.Black
            Me.BackColor = Color.FromArgb(&amp;HEB, &amp;HEB, &amp;HEB)
        Case AddinExpress.MSO.OfficeColorScheme.Blue
            Me.BackColor = Color.FromArgb(&amp;HD5, &amp;HE4, &amp;HF2)
        Case AddinExpress.MSO.OfficeColorScheme.Silver
            Me.BackColor = Color.FromArgb(&amp;HEE, &amp;HEE, &amp;HF4)
        Case AddinExpress.MSO.OfficeColorScheme.Unknown
            Me.BackColor = SystemColors.Control
    End Select
End Sub</code></pre>
<p>And that seems to be all! If you have any questions or comments, you are most welcome!</p>
<h3>You may also be interested in:</h3>
<p><a href="http://www.add-in-express.com/outlook-extension/">Advanced Outlook form and view regions</a><br />
<a href="http://www.add-in-express.com/add-in-net/outlook-regions.php">Customization of Reading pane, Outlook bar and To-Do bar</a><br />
<a href="http://www.add-in-express.com/creating-addins-blog/2009/02/26/2009-outlook-forms-zero-visibility/">Zero visibility for Outlook forms</a><br />
<a href="http://www.add-in-express.com/creating-addins-blog/2009/04/29/outlook-forms-minimized-restored/">Outlook forms: minimized, expanded, hidden</a> </p>
<h3>Available downloads:</h3>
<p>The sample add-ins below were written using <a href="http://www.add-in-express.com/add-in-net/"><strong>Add-in Express for Office and .net</strong></a></p>
<p><a href="http://www.add-in-express.com/files/howtos/blog/adx-office-2007-task-pane-color-cs.zip">C# sample Outlook and Excel add-in for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-office-2007-task-pane-color-vb.zip">VB.NET sample Outlook and Excel add-in for VS 2005</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/05/01/office-color-schemes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Office Alarm – Office Live Add-in and Word 2003</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/05/01/office-live-addin-word-2003/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/05/01/office-live-addin-word-2003/#comments</comments>
		<pubDate>Fri, 01 May 2009 15:01:05 +0000</pubDate>
		<dc:creator>Eugene Starostin</dc:creator>
				<category><![CDATA[Add-in Express .NET]]></category>
		<category><![CDATA[Add-in Express 2009]]></category>
		<category><![CDATA[Add-in Express VCL]]></category>
		<category><![CDATA[Add-in Express VSTO]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[COM add-ins]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Office]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VSTO]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=737</guid>
		<description><![CDATA[Strange things mentioned in my previous post continue to happen. To the bug successfully fixed in the Office Live Add-in on Excel 2007, there's added a nasty and so far no-solution problem with the same add-in, this time on Word 2003...]]></description>
			<content:encoded><![CDATA[<p>Strange things mentioned in my previous post continue to happen. To the bug successfully fixed in the <a href="http://www.add-in-express.com/creating-addins-blog/2009/04/30/office-live-addin-excel-crash/">Office Live Add-in on Excel 2007</a>, there&#8217;s added a nasty and so far no-solution problem with the same add-in, this time on Word 2003.</p>
<h2>Why does Office Live Add-in replace my menu on Word 2003?</h2>
<p>My add-in creates a new item in the main menu of Word 2003. Here&#8217;s how it looks like – see <em>My Menu Item</em> in the picture below:</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/office-live-add-in-on-word-1.png" alt="Custom menu item after 1st start of Word" width="656" height="485" /></p>
<p>After the first start of the add-in all was fine. The second start of Word, however, made me strain myself, rub my eyes and open them again – just have a look at <em>My Menu Item</em> in this picture:</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/office-live-add-in-word.png" alt="Custom menu item after 2nd start of Word" width="656" height="485" /></p>
<p>It took me some time to understand what&#8217;s going on before I gathered wits to switch off the Office Live Add-in. We found out that the framework on which the add-in is written doesn&#8217;t matter at all, whether it be an Add-in Express based add-in or a &#8220;plain shared add-in&#8221; (I need to remember this phrase) or a VSTO-based add-in.</p>
<h2>Workaround</h2>
<p>For the moment, the only solution is to disable the Office Live Add-in.</p>
<h2>Applies to</h2>
<p>The problem occurs only on Word 2003 (all service packs and updates installed) with <em>Office Live Add-in Update 1.3</em> installed (OLConnector.dll version is 2.0.2313.0).</p>
<h2>What about Add-in Express?</h2>
<p>We are yet to find a decent workaround.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/05/01/office-live-addin-word-2003/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Office Alarm – Excel experienced a serious problem with the ‘microsoft office live add-in’</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/04/30/office-live-addin-excel-crash/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/04/30/office-live-addin-excel-crash/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 14:56:18 +0000</pubDate>
		<dc:creator>Eugene Starostin</dc:creator>
				<category><![CDATA[Add-in Express .NET]]></category>
		<category><![CDATA[Add-in Express 2009]]></category>
		<category><![CDATA[Add-in Express VCL]]></category>
		<category><![CDATA[Add-in Express VSTO]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[COM add-ins]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Office]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=715</guid>
		<description><![CDATA[Strange things started happening around us. Pig flu added to the global economic crisis, and we have problems with Office 2007 and the Office Live Add-in added to our pre-release testing for compatibility with the recently released Office Service Pack 2. The fact of the matter is that...]]></description>
			<content:encoded><![CDATA[<p>Strange things started happening around us. Pig flu added to the global economic crisis, and we have problems with Office 2007 and the Office Live Add-in added to our pre-release testing for compatibility with the recently released Office Service Pack 2. The fact of the matter is that&#8230;</p>
<h2>&#8220;Microsoft Office Excel has stopped working&#8221; or how to crash Excel 2007 with the Office Live Add-in step-by-step</h2>
<ul class="list">
<li>Check out if you have Office Live Add-in Update 1.3. installed.</li>
<li>Load Visual Studio 2008, create a Windows Forms application.</li>
<li>Add a reference to <em>Microsoft Excel 12.0 Object Library</em> to your project.</li>
<li>Add a button to the form and handle it with the following code: </li>
</ul>
<pre class="SrcCode"><code class="vb">
    Private Sub Button1_Click(ByVal sender As System.Object,_
        ByVal e As System.EventArgs) Handles Button1.Click

        Dim app As Excel.Application = New Excel.Application()
        app.Visible = True
        app.Quit()

    End Sub
</code></pre>
<ul class="list">
<li>Important! Disable all network connections.</li>
<li>Important! Unload all Office applications.</li>
<li>Run the project, click the button.</li>
<li>And voilà: <em>Microsoft Office Excel has stopped working</em>:</li>
</ul>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/microsoft-office-excel-has-stopped-working.png" alt="Microsoft Office Excel has stopped working" width="366" height="183" /></p>
<ul class="list">
<li>Click <em>Close program</em>, close the project.</li>
<li>Start Excel manually and here&#8217;s what we get: <em>Excel experienced serious problems with the microsoft office live add-in</em>:</li>
</ul>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/excel-experienced-serious-problem-with-microsoft-office-live-add-in-add-in.png" alt="Excel experienced a serious problem with microsoft office live add-in" width="496" height="197" /></p>
<h2>Workaround</h2>
<p>It all lies in a nutshell! Just give your processor some time to cool down :)</p>
<pre class="SrcCode"><code class="vb">
Private Sub Button1_Click(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles Button1.Click

Dim app As Excel.Application = New Excel.Application()
app.Visible = True

System.Threading.Thread.Sleep(1000) ' &lt;=== Workaround!!!

app.Quit()

End Sub</code></pre>
<h3>You need to disable the Office Live Add-in if…</h3>
<p>Righto, if <em>Dr. Watson</em> reports make you feel giddy, you need to disable the Office Live Add-in :)</p>
<h2>Applies to</h2>
<p>The problem occurs only on Excel 2007 (without SP, with SP1, with SP2) with <em>Office Live Add-in Update 1.3</em> installed (OLConnector.dll version is 2.0.2313.0). Well then, no Windows update will help, even despite the fact that Office Live Add-in, Update 1.3 comes as part of Microsoft Optional software update.</p>
<h2>What about Add-in Express?</h2>
<p>At first sight, the code sample above is of no use at all – it opens and closes Excel straight away. However, this is at first glance only. In fact, a great deal of useful code can be put between <strong>New Excel.Application()</strong> and <strong>app.Quit()</strong>. For example, Add-in Express acts exactly according to this model when cleaning up all traces of the add-in when it is being unregistered. And it was unregistration of add-ins when we ran into the problem of Excel 2007 + Office Live Add-in. But that&#8217;s not the half of the Office Live Add-in. To be continued&#8230;</p>
<h3>You may also be interested in:</h3>
<p><a href="http://www.add-in-express.com/docs/net-first-com-addin.php">Creating Excel COM add-in step-by-step</a><br />
<a href="http://www.add-in-express.com/docs/net-excel-automation-addins.php">Developing Excel Automation add-in in .net</a><br />
<a href="http://www.add-in-express.com/docs/vcl-excel-automation-addins.php">Building Excel Automation add-ins in Delphi</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/04/30/office-live-addin-excel-crash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hint: How to completely reset Outlook regions</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/04/29/resetting-outlook-regions/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/04/29/resetting-outlook-regions/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 16:21:06 +0000</pubDate>
		<dc:creator>Eugene Starostin</dc:creator>
				<category><![CDATA[Add-in Express .NET]]></category>
		<category><![CDATA[Add-in Express 2009]]></category>
		<category><![CDATA[Add-in Express VCL]]></category>
		<category><![CDATA[Add-in Express VSTO]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[Outlook regions]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VSTO]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=706</guid>
		<description><![CDATA[When Outlook is closing, Add-in Express saves the state of all regions embedded into Outlook, namely their position (if drag-and-drop is turned on), state (regions can be minimized or entirely hidden) and size (if resizing is allowed). We implemented this feature just to give end-users the utmost comfort when working with Outlook regions...]]></description>
			<content:encoded><![CDATA[<p>When Outlook is closing, Add-in Express saves the state of all regions embedded into Outlook, namely their position (if <a href="http://www.add-in-express.com/creating-addins-blog/2009/04/03/outlook-drag-drop-forms/">drag-and-drop</a> is turned on), state (regions can be minimized or entirely hidden) and size (if resizing is allowed). We implemented this feature only in order to give end-users maximum comfort when working with Outlook regions. But because of this very ability, quite comfortable for the end-user, I often find myself in the situation when I want to see the initial state of my regions once again, but by this time I have leant over backwards and dragged some of the regions to sub-panes different from default, hid others and minimized the rest. Unregister-register will be of no help, since Add-in Express stores the regions state in a common for all add-ins storage area.</p>
<p>Earlier, prior to version 2009, I had to unregister my add-in, delete a couple or a few more keys from the registry, and after that register the add-in anew. But by the time of version 2009, my patience had given out and our developers had to strain their efforts to provide an easy and accessible way of resetting the state of all Outlook regions. Note, this works on Add-in Express 2009 only!</p>
<h2>Add-in Express 2009 for Office and .net (and VSTO too)</h2>
<p>For <a href="http://www.add-in-express.com/add-in-net/">Add-in Express for .net</a> and <a href="http://www.add-in-express.com/add-in-vsto/">Add-in Express for VSTO</a>, to reset all Outlook view and form regions, right click on the Outlook Forms Manager component and select <em>Reset Regions</em>:</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/reset-outlook-regions-visua.png" alt="Resetting Outlook regions in .net" width="598" height="503" /></p>
<h2>Add-in Express 2009 for Office and CodeGear VCL</h2>
<p>For <a href="http://www.add-in-express.com/add-in-delphi/">Add-in Express for VCL</a>, to reset all Outlook view and form regions, right click on the Outlook Forms Manager component and select <em>Reset Regions</em>:</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/reset-outlook-regions-delph.png" alt="Resetting Outlook regions in Delphi" width="327" height="371" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/04/29/resetting-outlook-regions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Complete review – Advanced Outlook Regions, part 4</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/04/29/outlook-forms-minimized-restored/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/04/29/outlook-forms-minimized-restored/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 15:45:37 +0000</pubDate>
		<dc:creator>Eugene Starostin</dc:creator>
				<category><![CDATA[Add-in Express .NET]]></category>
		<category><![CDATA[Add-in Express 2009]]></category>
		<category><![CDATA[Add-in Express VCL]]></category>
		<category><![CDATA[Add-in Express VSTO]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[Outlook regions]]></category>
		<category><![CDATA[task panes]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[VSTO]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=694</guid>
		<description><![CDATA[In version 2009 of Add-in Express, a new property appears - RestoreFromMinimizedState. Now I will show you its behavior. Let's say, we have a minimized by default region...]]></description>
			<content:encoded><![CDATA[<p>Today we will revert to pictures, because I am going to speak again about usability and visibility :)</p>
<h2>The RestoreFromMinimizedState property</h2>
<p>In version 2009, there appears a new property &#8211; <em>RestoreFromMinimizedState</em>. Now I will show you its behavior. Let&#8217;s say, we have a minimized by default region, see the picture below:</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/minimized-outlook-regions.png" alt="Minimized Outlook regions" width="630" height="535" /></p>
<p>By default (when <em>RestoreFromMinimizedState</em> = False), when clicking the icon of one of the region&#8217;s forms, this form is expanded over the content of the parent window, you can see the form overlaying the content of the Explorer window in the picture below:</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/expanded-outlook-regions.png" alt="Expanded Outlook regions" width="630" height="535" /></p>
<p>As a matter of fact, the minimized Navigation Pane behaves in the same way (though, it allows resizing&#8230; hmm&#8230; we ought to do this as well :)</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/expanded-navigation-pane.png" alt="Expanded Navigation pane" width="630" height="535" /></p>
<p>If you set <em>RestoreFromMinimizedState</em> to True, then upon clicking an icon of one of the region&#8217;s forms, this form is completely restored:</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/restored-outlook-regions.png" alt="Restored Outlook regions" width="630" height="535" /></p>
<p>By the way, our task panes have the same property. And this is particularly crucial, for example, for Excel. Say, we have a table like this:</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/minimized-excel-task-pane.png" alt="Minimized Excel task pane" width="483" height="458" /></p>
<p>A click on the form&#8217;s icon, the form is expanded and overlays not only the active cell and the mouse pointer, but practically the entire table as well. You can see it in this picture:</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/expanded-excel-task-pane.png" alt="Expanded Excel task pane" width="483" height="458" /></p>
<p>To avoid this, you simply set the <em>RestoreFromMinimizedState</em> property to True.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/04/29/outlook-forms-minimized-restored/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo: Identify the state and location of an Outlook form</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/04/24/outlook-form-state-location/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/04/24/outlook-form-state-location/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 19:05:45 +0000</pubDate>
		<dc:creator>Dmitry Kostochko</dc:creator>
				<category><![CDATA[HowTo samples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[COM add-ins]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[Outlook regions]]></category>
		<category><![CDATA[task panes]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=680</guid>
		<description><![CDATA[Add-in Express 2008 allows placing several forms into one Outlook region or task pane. In addition, Add-in Express 2009 enables the end-user to drag and drop custom forms to wherever they want to (naturally, with the developer's permission). Do you need to know where your form is now and in what state? Of course, you do…]]></description>
			<content:encoded><![CDATA[<p>Add-in Express 2008 allows placing several forms into one Outlook region or task pane. In addition, <a href="http://www.add-in-express.com/creating-addins-blog/cat/addin-express-2009/">Add-in Express 2009</a> enables the end-user to <a href="http://www.add-in-express.com/creating-addins-blog/2009/04/03/outlook-drag-drop-forms/">drag and drop custom forms</a> to wherever they want (naturally, with the developer&#8217;s permission). Do you need to know where your form is now and in what state? Of course, you do.</p>
<p>Normally, you may need this, for example, to update data only in visible forms / task panes. So, here goes! In our sample add-in, we are going to embed custom forms into the Outlook Explorer and Outlook Inspector windows, two forms into each. In this example, we need to know which of the window types, explorer or inspector, a given form belongs to and somehow identify this form, say, by its caption. All this can be done in the <em>ADXBeforeShow</em> event handler:</p>
<pre class="SrcCode"><code class="vb">
Private isExplorer As Boolean = False

Private Sub ADXOlForm1_ADXBeforeFormShow() _
    Handles MyBase.ADXBeforeFormShow

    If Me.Text = "ADXOlForm1" Then
        If Me.ExplorerObj IsNot Nothing Then
            Me.isExplorer = True
            Me.Text = "Explorer Form " + _
             (Me.Item.Collection.IndexOf(Me.Item) - 1).ToString()
        End If
        If Me.InspectorObj IsNot Nothing Then
            Me.isExplorer = False
            Me.Text = "Inspector Form " + _
             (Me.Item.Collection.IndexOf(Me.Item) + 1).ToString()
        End If
    End If
End Sub</code></pre>
<p>We can identify the Outlook region in which your form appears at this very moment using the following code:</p>
<pre class="SrcCode"><code class="vb">
Public Function GetFormRegion(ByVal Instance As ADXOlForm) As Object
    If DirectCast(Instance, ADXOlForm1).isExplorer Then
        Return Instance.Item.ExplorerLayout
    End If
    Return Instance.Item.InspectorLayout
End Function</code></pre>
<p>The next question is the form state. To identify the state, I suggest using the following type:</p>
<pre class="SrcCode"><code class="vb">
Public Enum FormState
    Focused
    Visible
    InRegion
    InCache
End Enum</code></pre>
<p>And here&#8217;s what the terms above mean:</p>
<ul class="list">
<li>Focused – Outlook form is visible, active, the focus is on the form.</li>
<li>Visible – Outlook form is visible.</li>
<li>InRegion – Outlook form is in the region, but is not visible. It may, e.g. be overlaid with another form, or be in the Minimized or Hidden state.</li>
<li>InCache – Outlook form is in Cache. A form instance is created by default for each Outlook folder which was opened.</li>
</ul>
<p>The code below will return us the form state:</p>
<pre class="SrcCode"><code class="vb">
Public Function GetFormState(ByVal Instance As ADXOlForm) As FormState
    If Instance.Visible AndAlso _
        Instance.Active AndAlso _
        CheckFocused(Instance) Then
        Return FormState.Focused
    End If
    If Instance.Visible AndAlso Instance.Active Then
        Return FormState.Visible
    End If
    If Instance.Visible Then
        Return FormState.InRegion
    End If
    Return FormState.InCache
End Function

Public Function CheckFocused(ByVal Instance As ADXOlForm) As Boolean
    For I As Integer = 0 To Instance.Controls.Count - 1
        If Instance.Controls(I).Focused Then
            Return True
        End If
    Next I
    Return False
End Function</code></pre>
<p>Now we need to iterate the <em>ADXOlFormsManager.Items</em> collection, get all form instances by using the <em>FormInstances</em> method, then get the form state and the region in which the form is located, and output the result:</p>
<pre class="SrcCode"><code class="vb">
Private Sub ButtonCheckForms_Click(ByVal sender As _
    System.Object, ByVal e As System.EventArgs) _
    Handles ButtonCheckForms.Click

    Dim text As String = String.Empty
    Dim I, J As Integer
    For I = 0 To Me.FormsManager.Items.Count - 1
        For J = 0 To Me.FormsManager.Items(I).FormInstanceCount - 1
            Dim form As ADXOlForm = _
                Me.FormsManager.Items(I).FormInstances(J)
            If form IsNot Nothing AndAlso form IsNot Me Then
                text = text + _
                    form.Text + Environment.NewLine + _
                    "State: " + GetFormState(form).ToString() + _
                    Environment.NewLine + _
                    "Region: " + GetFormRegion(form).ToString() + _
                    Environment.NewLine + Environment.NewLine
                DirectCast(form, ADXOlForm1).TextBoxDetails.Clear()
            End If
        Next J
    Next I

    TextBoxDetails.Text = _
        "--- THIS FORM: ---" + Environment.NewLine + _
        Me.Text + Environment.NewLine + _
        "State: " + GetFormState(Me).ToString() + _
        Environment.NewLine + _
        "Region: " + GetFormRegion(Me).ToString() + _
        Environment.NewLine + Environment.NewLine + _
        "--- OTHER FORMS: ---" + Environment.NewLine + _
        text
End Sub</code></pre>
<p>If you have any questions or comments, you are most welcome!</p>
<p><strong>For more information about Advanced Outlook Regions see:</strong><br />
<a href="http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-forms-regions/">Complete review: Advanced Outlook Regions basics</a><br />
<a href="http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-explorer-inspector-regions/">Complete review: Outlook Explorer and Inspector regions</a><br />
<a href="http://www.add-in-express.com/creating-addins-blog/2009/04/22/outlook-regions-read-compose/">Complete review: Outlook Regions – cached instancing, exposing events, read and compose</a></p>
<h3>Available downloads:</h3>
<p><font color=red><strong>Note!</strong></font> The samples below are built using <a href="http://www.add-in-express.com/creating-addins-blog/cat/addin-express-2009/">generation 2009 of Add-in Express</a>.</p>
<p><a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-forms-state-cs.zip">C# sample Outlook add-in for VS 2005</a><br /><a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-forms-state-vb.zip">VB.NET sample Outlook add-in for VS 2005</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/04/24/outlook-form-state-location/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Complete review – Advanced Outlook Regions, part 3</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/04/22/outlook-regions-read-compose/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/04/22/outlook-regions-read-compose/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 14:35:09 +0000</pubDate>
		<dc:creator>Eugene Starostin</dc:creator>
				<category><![CDATA[Add-in Express .NET]]></category>
		<category><![CDATA[Add-in Express 2009]]></category>
		<category><![CDATA[Add-in Express VCL]]></category>
		<category><![CDATA[Add-in Express VSTO]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Office]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[Outlook regions]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VSTO]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=648</guid>
		<description><![CDATA[Part 2 of the Advanced Outlook Regions series, which focused on Outlook Explorer and Inspector regions, ended with the promise that there would be no pictures in the upcoming post, instead it would touch on rather unobvious, rarely used, but highly interesting stuff.  Well, the first thing that I'd like to start with is cached instancing...]]></description>
			<content:encoded><![CDATA[<p>My previous post, which focused on <a href="http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-explorer-inspector-regions/">Outlook Explorer and Inspector regions</a>, ended with the promise that there would be no pictures in the upcoming post, instead it would touch on rather unobvious, rarely used, but highly interesting stuff. Well, the first thing that I&#8217;d like to start with is cached instancing.</p>
<h2>Cached instancing</h2>
<p>Oh yes, there turned out to be room for the word that has a smell of something lower-level than forms embedded into Outlook. I am speaking about the Cached property of the Outlook Forms Manager component and about creating instances of your forms.</p>
<p>This property and its &#8220;mechanics&#8221; are described best on the <a href="http://www.add-in-express.com/docs/outlook-cached-forms.php">Cached Outlook forms</a> page. I&#8217;ll just point out that setting <em>OneInstanceForAllFolders</em> considerably speeds up the work of the add-in and Outlook itself. So, it would be unwise to shrug off this fact.</p>
<h2>Outlook events exposed by the Add-in Express Outlook Forms Manager</h2>
<p>Besides a number of Outlook events that are quite frequently used in add-in development, e.g. <em>SelectionChange</em>, <em>FolderSwitch</em> and <em>NewInspector</em>, the Add-in Express Outlook Forms Manager component (which is the heart of the Advanced Outlook Regions) exposes several other events inaccessible through the Outlook object model. Here they are:</p>
<ul class="list">
<li><em>NavigationPaneHide</em>, <em>NavigatioPaneShow</em>, <em>NavigationPaneMinimize</em> – these names speak for themselves, don&#8217;t they?</li>
<li><em>TodoBarHide</em>, <em>TodoBarShow</em>, <em>TodoBarMinimize</em> – names of these events are rather expressive as well.</li>
<li><em>ReadingPaneHide</em>, <em>ReadingPaneShow</em>, <em>ReadingPaneMove</em> &#8211; hide and show events are easy-to-understand, as to the Move event, I will note that it fires when the Outlook Reading Pane is moved from the bottom to the right and vice versa.</li>
</ul>
<h2>Inspector mode &#8211; read and compose</h2>
<p>In addition to the earlier existing methods of binding Outlook regions to context (see <a href="http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-forms-regions/#context">Context is a brilliant</a> in <a href="http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-forms-regions/">Advanced Outlook Form and View Regions, part 1</a>), version 2009 allows showing regions separately for read or compose inspector mode. For instance, you can show your regions only when the end-user is editing an e-mail message or reading a received meeting request. However, you should clearly understand which of Outlook items can be opened in this or that mode, and how a given mode is determined. I tried to put all information together in a table, and here&#8217;s what I have come up with:</p>
<table class="TableWideBorder" border="0" cellspacing="1" cellpadding="0">
<tbody>
<tr valign="top">
<th>Item Type</th>
<th>Item.MessageClass</th>
<th>Ribbon</th>
<th>How read / compose mode is determined</th>
</tr>
<tr class="odd" valign="top">
<td>Appointment</td>
<td>IPM.Appointment.*</td>
<td>OutlookAppointment</td>
<td>Appointments are always opened in compose mode</td>
</tr>
<tr valign="top">
<td>Contact</td>
<td>IPM.Contact.*</td>
<td>OutlookContact</td>
<td>Contacts are always opened in compose mode</td>
</tr>
<tr class="odd" valign="top">
<td>Journal</td>
<td>Journal IPM.Activity.*</td>
<td>OutlookJournal</td>
<td>Journal items are always opened in compose mode</td>
</tr>
<tr valign="top">
<td>Mail</td>
<td>IPM.Note.*</td>
<td>OutlookMailRead<br />
OutlookMailCompose</td>
<td>Read mode if Item.Sent = True<br />
Compose mode if Item.Sent = False</td>
</tr>
<tr class="odd" valign="top">
<td>Meeting</td>
<td>IPM.Schedule.Meeting.*</td>
<td>OutlookMeetingRequestRead<br />
OutlookMeetingRequestSend</td>
<td>Read mode if Item.Sent = True<br />
Compose mode if Item.Sent = False</td>
</tr>
<tr valign="top">
<td>Post</td>
<td>IPM.Post.*</td>
<td>OutlookPostRead<br />
OutlookPostCompose</td>
<td>Compose mode if Item.Saved = False or Item.Size = 0, else Read mode<br />
For Outlook 2007:<br />
Compose mode if WordEditor.ProtectionType = wdNoProtection, else Read mode</td>
</tr>
<tr class="odd" valign="top">
<td>Task</td>
<td>IPM.Task.*</td>
<td>OutlookTask</td>
<td>Tasks are always opened in compose mode</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/04/22/outlook-regions-read-compose/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo:  Work with threads in Microsoft Office COM add-ins</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/04/17/office-addins-threads/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/04/17/office-addins-threads/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 17:51:54 +0000</pubDate>
		<dc:creator>Dmitry Kostochko</dc:creator>
				<category><![CDATA[HowTo samples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[COM add-ins]]></category>
		<category><![CDATA[Office]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=634</guid>
		<description><![CDATA[It is generally known that the Microsoft Office Object Model is not thread safe and accessing some object, property or method not from the main thread may sometimes result in a host application crash. Of course, nothing prevents you from using threads inside the add-in itself, threads that don't need the Office Object Model...]]></description>
			<content:encoded><![CDATA[<p>It is generally known that the Microsoft Office Object Model is not thread safe and accessing some object, property or method not from the main thread of a COM add-in may sometimes result in a host application crash. Of course, nobody prevents you from using threads inside the Office COM add-in itself, the threads that don&#8217;t need the Office Object Model.</p>
<p>In our today&#8217;s VB.NET example (a C# sample is available for download at the bottom of the page), we are going to fill in the <em>DataGridView</em> component, which is located in the Outlook Explorer window, with data by using a background thread. Here&#8217;s the code that runs the thread and adds a hundred lines to the <em>DataGridView.Rows</em> collection:</p>
<pre class="SrcCode"><code class="vb">
Private Sub startButton_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles startButton.Click
    startButton.Enabled = False
    myThread = New Thread(AddressOf StartThread)
    myThread.Start()
End Sub

Private Sub StartThread()
    SyncLock ThreadRunningObj
        FlagThreadRunning = True
    End SyncLock
    Try
        Dim nameColumn As String
        Dim timeStamp As String
        Dim boolColumn As Boolean = True
        For i As Integer = 1 To 100
            nameColumn = "Record " &amp; i.ToString()
            timeStamp = DateTime.Now.ToString()
            boolColumn = Not boolColumn
            AddRow(nameColumn, timeStamp, boolColumn)
            Thread.Sleep(1000)
            If Not FlagThreadRunning Then
                Exit Try
            End If
        Next
        SetEnabled(True)
    Finally
        SyncLock ThreadRunningObj
            FlagThreadRunning = False
        End SyncLock
    End Try
End Sub
</code></pre>
<p>Naturally, besides launching we need to stop the thread. Let&#8217;s do it with some stop button:</p>
<pre class="SrcCode"><code class="vb">
Private Sub stopButton_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles stopButton.Click
    StopThread()
    startButton.Enabled = True
End Sub

Private Sub StopThread()
    SyncLock ThreadRunningObj
        FlagThreadRunning = False
    End SyncLock
    myThread.Join()
End Sub
</code></pre>
<p>One more note. You have to stop the additional thread not only upon clicking the <em>Stop</em> button, but also when closing the host application. In our sample, it should be done in the <em>Dispose</em> method:</p>
<pre class="SrcCode"><code class="vb">
Protected Overloads Overrides Sub Dispose( _
  ByVal disposing As Boolean)
    If disposing Then
        If myThread IsNot Nothing Then
            StopThread()
        End If
        If Not (components Is Nothing) Then
            components.Dispose()
        End If
    End If
    MyBase.Dispose(disposing)
End Sub
</code></pre>
<p>That&#8217;s all for today. If you have any questions or comments, don&#8217;t hesitate to post them!</p>
<h3>You may also be interested in:</h3>
<p><a href="http://www.add-in-express.com/add-in-net/com-addins.php">How to create Office COM addin in .net</a><br />
<a href="http://www.add-in-express.com/add-in-delphi/com-addins.php">Build COM add-in for Office 2000 &#8211; 2007 in Delphi</a></p>
<h3>Available downloads:</h3>
<p><a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-threads-cs.zip">C# sample Outlook add-in for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-threads-vb.zip">VB.NET sample Outlook add-in for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-threads-d7.zip">Delphi sample Outlook add-in for Delphi 7</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/04/17/office-addins-threads/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Complete review – Advanced Outlook Regions, part 2</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-explorer-inspector-regions/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-explorer-inspector-regions/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 16:35:33 +0000</pubDate>
		<dc:creator>Eugene Starostin</dc:creator>
				<category><![CDATA[Add-in Express .NET]]></category>
		<category><![CDATA[Add-in Express 2009]]></category>
		<category><![CDATA[Add-in Express VCL]]></category>
		<category><![CDATA[Add-in Express VSTO]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[Outlook regions]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VSTO]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=609</guid>
		<description><![CDATA[My previous post was about what the Advanced Outlook Regions really are. And now I will show you all possible regions for two main Outlook windows - Explorers and Inspectors. In this post there are a lot of pictures and little text. As usually, all the forms that I am going to demonstrate do not have a single control...]]></description>
			<content:encoded><![CDATA[<p>My previous post was about <a href="http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-forms-regions/">what the Advanced Outlook Regions really are</a>. And now I will show you all possible variants of regions for two main Outlook windows &#8211; Explorers and Inspectors. In this post, there will be a lot of pictures and little text. As usually, all the forms that I am going to demonstrate do not have a single control.</p>
<p>At the very beginning of their history, the Advanced Outlook Regions were totally based on the Microsoft Office 2003 terminology, that is why you may find some discrepancies in the names of the regions supported at that time and in the more recent regions&#8217; names. The point is that in those, in fact, not very old days nobody could fancy that Microsoft would release their version of regions and would call them Outlook form regions. Then two nouns were used in the description of the Outlook windows elements &#8211; panes and subpanes. For this reason, beside the pictures I will give the specific name of the region, which is used in the ExplorerLayout and InspectorLayout properties of the Add-in Express Outlook Forms Manager component.</p>
<h3>Outlook Explorer regions and Outlook view regions</h3>
<p>To denote regions that can be created in the Outlook Explorer window, we use two interchangeable phrases &#8211; &#8220;Outlook Explorer regions&#8221; and &#8220;Outlook view regions&#8221;, even despite the fact that the View pane (an area containing, for example, a grid with e-mails in mail folders) is just a part of the Outlook Explorer window.</p>
<h3>Outlook Inspector regions and Outlook form regions</h3>
<p>For regions in the Outlook Inspector window, we employ the same approach and use two interchangeable phrases &#8211; &#8220;Outlook Inspector regions&#8221; and &#8220;Outlook form regions&#8221;.</p>
<h2>Outlook view regions</h2>
<p>All regions that you can use in Outlook Explorer windows are grouped together under this common name. However, there is always an opportunity to specify the region more precisely by using the following more accurate names:</p>
<ul class="list">
<li>Folder view regions</li>
<li>Reading pane regions</li>
<li>To-Do Bar region</li>
<li>Navigation Pane region</li>
<li>Outlook bar region</li>
<li>WebView pane region</li>
</ul>
<p>You will find more details about each of them below.</p>
<h3>Folder view regions</h3>
<p>Let&#8217;s start with four regions located around the View pane. Here are their names according to the ExplorerLayout property: LeftSubpane, TopSubpane, BottomSubpane, RightSubpane. In these names, you can notice an evident terminology of the Office 2003 times.</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/outlook-folder-view-regions.png" alt="Folder view regions" width="630" height="535" /></p>
<p>In the screenshot above I deliberately hid the Outlook To-Do bar and the Reading pane. Here is what we get if to turn them on:</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/outlook-folder-view-regions-2.png" alt="Outlook To-Do bar and the Reading pane regions" width="630" height="535" /></p>
<p>Don&#8217;t you agree that it looks too variegated? I hope nobody is going to use all the four regions in such parrot-like coloring :) And here&#8217;s how the most frequently used pattern looks like &#8211; in this case the top region includes a folder-specific toolbar:</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/outlook-folder-view-regions-3.png" alt="Outlook region with a folder-specific toolbar" width="630" height="535" /></p>
<h3>Reading Pane regions</h3>
<p>Regions around the Reading pane are complete analogues of the previously shown regions, they embed forms like this:</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/outlook-reading-pane-regions.png" alt="Regions around the Outlook Reading pane" width="630" height="535" /></p>
<p>These are their names for the ExplorerLayout property: LeftReadingPane, TopReadingPane, BottomReadingPane, RightReadingPane.</p>
<h3>To-Do Bar, Navigation Pane and Outlook Bar region</h3>
<p>Practically all panes of the Outlook Explorer windows can include regions. Besides the above mentioned regions there are two more: BottomNavigationPane and BottomTodoBar in the ExplorerLayout property (for Outlook 2000 and 2002 there is yet another one &#8211; BottomOutlookBar region). You can see these two regions in the following picture:</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/outlook-to-do-bar-regions.png" alt="To-Do Bar, Navigation Pane and Outlook Bar region" width="630" height="535" /></p>
<p>Both the Outlook Navigation Pane and To-Do Bar (oh yes, and Outlook Bar in Office 2002) can be hidden or minimized. In this case the regions that they contain will be hidden.</p>
<h3>WebViewPane region</h3>
<p>WebViewPane is the name of one more region from the ExplorerLayout property. The WebViewPane region totally replaces the content of the View pane (the region is based on the folder home pages). The most frequent use of the region is to replace some folder&#8217;s view with its form. In principle, when using this solution nothing prevents you from hosting any application into Outlook, allocating its interface into the folders created for this occasion. The best examples of such applications are Outlook Business Contact Manager and Outlook Client for Microsoft CRM.</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/outlook-folder-region.png" alt="Outlook WebViewPane region" width="630" height="535" /><br />
<a name="outlook-form-regions"></a><br />
<h2>Outlook form regions</h2>
<p>For Outlook Inspector window, you can use any of the four regions available in the InspectorLayout property: LeftSubpane, TopSubpane, BottomSubpane, RightSubpane (their names sprout up from the Outlook 2003 terminology):</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/outlook-form-regions.png" alt="Regions for the Outlook Inspector window" width="616" height="523" /></p>
<h3>Regions and &#8220;zero-visibility&#8221;</h3>
<p>Finally, there are three quite specific regions, which are described separately in <a href="http://www.add-in-express.com/creating-addins-blog/2009/03/02/outlook-region-zero-visibility/">Add-in Express 2009, beta 1 - Zero-visibility for Outlook regions, part 2</a>. You will find a couple of interesting pictures there as well :)</p>
<p>BTW, the next post will not have such colorful pictures, enjoy them now :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-explorer-inspector-regions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Complete review – Advanced Outlook Regions, part 1</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-forms-regions/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-forms-regions/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 15:50:08 +0000</pubDate>
		<dc:creator>Eugene Starostin</dc:creator>
				<category><![CDATA[Add-in Express .NET]]></category>
		<category><![CDATA[Add-in Express 2009]]></category>
		<category><![CDATA[Add-in Express VCL]]></category>
		<category><![CDATA[Add-in Express VSTO]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[Outlook regions]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[VSTO]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=602</guid>
		<description><![CDATA[Our web-site somehow absolutely imperceptibly for me turned into a collection of pages containing a bit outdated information about our products. I think we will spend the whole year 2009 on putting our web-site in order. In the meantime, I am going to systematically publish complete reviews of one or other of the capabilities that, in my opinion, are covered insufficiently or their descriptions are outdated. And I will start with perhaps the most popular feature of Add-in Express - the Advanced Outlook View and Form Regions...]]></description>
			<content:encoded><![CDATA[<p>Our web-site somehow absolutely imperceptibly for me has turned into a collection of pages containing a bit outdated information about our products. I think we will spend the whole year 2009 on putting our site in order. In the meantime, I am going to systematically publish comprehensive reviews depicting one or other of the capabilities that, in my opinion, are covered insufficiently, or their descriptions are outdated. And I will start with perhaps the most popular feature of Add-in Express &#8211; the Advanced Outlook View and Form Regions.</p>
<p>So far this technology, which is included in all the three editions of Add-in Express for Office (.net, VCL and VSTO), was presented in the specially dedicated section &#8211; <a href="http://www.add-in-express.com/outlook-extension/">Customization of Outlook forms and views</a>, and it is this section that contains the least actual information about our Outlook regions. In addition, you can find something on the pages devoted to a particular edition of Add-in Express for Office:</p>
<ul class="list">
<li><a href="http://www.add-in-express.com/add-in-net/outlook-regions.php">Advanced Outlook view and forms regions</a> in Add-in Express for Office and .net</li>
<li><a href="http://www.add-in-express.com/add-in-vsto/outlook.php">Outlook-specific features</a> in Add-in Express for Office and VSTO</li>
<li><a href="http://www.add-in-express.com/add-in-delphi/outlook-regions.php">Outlook view and form regions</a> in Add-in Express for Office and VCL</li>
</ul>
<p>Besides that, <a href="http://www.add-in-express.com/creating-addins-blog/author/andrei-smolin/">Andrei</a> depicted the programming side of these regions in corresponding <a href="http://www.add-in-express.com/docs/">Developer&#8217;s Guides</a>. However, all the above mentioned does not give a complete overview of the technology. In fact, a familiarization tour of our Outlook regions should be started with&#8230;</p>
<h2>What is the Advanced Outlook View and Form Regions?</h2>
<p>Formally, I would define them in this way: The Advanced Outlook View and Form Regions is a technology included in all editions of <em>Add-in Express for Office</em> that allows a developer to embed their forms into the Outlook GUI. Informally, I would put it like this: this is what can overthrow your views on building the user interface of your Outlook add-ins. The key point here is to remember that a form is not necessarily something big and &#8220;multicontrol&#8221;, like Outlook Explorer or the main Outlook Options dialog box. I&#8217;m giving a hint! A toolbar is also a form. And a single button with a vivid icon is a toolbar as well&#8230; :)</p>
<h3>The Advanced Outlook Regions work on Outlook 2000 &#8211; 2007</h3>
<p>You have just read the most essential note in the heading. This is true &#8211; you can use the Advanced Outlook Regions on all Outlook versions starting from Outlook 2000.</p>
<h3><a name="context"></a>Context is a brilliant</h3>
<p>One more note before we proceed to pictures. Using the regions, you not only embed your forms into the Outlook GUI, but also bind them to a context. For example, you can bind your forms to one or several folders by their names or type (you can show your form for folders with tasks only). You can also bind your forms to your custom Outlook forms (you are still using custom Outlook forms, aren&#8217;t you?) through the message classes on which they are based (see PR_MESSAGE_CLASS in MAPI). In addition, by using the corresponding events this context-sensitivity can be programmed a little (or much) to make binding your forms to context utmost flexible. That&#8217;s all, let&#8217;s move to the pictures&#8230;</p>
<h3>Regions as they are</h3>
<p>The picture below shows the main Outlook window with one region between the folder view pane and To-Do bar (the latter is minimized).</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/outlook-region-sample-1.png" alt="Outlook region between the folder view pane and To-Do bar " width="630" height="535" /></p>
<p>The region contains an embedded form (I colored it in green) and the region header with several controls. Instead of the green background you can, naturally, place any controls from your collection and even fill them with some data ;-) Well, I am not going to linger round this subject now. As for the header, it is worth dwelling on. The first two buttons with right and left arrows allow quick switching between previous-next forms embedded into the region. A click on the form&#8217;s icon (in my case, it is a green-roofed home), on the form&#8217;s caption or a down arrow will open a list of all forms contained in the region. To the right of the cross button that customarily closes the current form, there is a button with two right arrows (&gt;&gt;) that allows minimizing the region. I&#8217;d also like to draw your attention to the splitter to the left of the region. A double click on it hides the region. In the picture above you see the region in its normal state (there is a special property &#8211; DefaultRegionState).</p>
<p><em>Note! Regions can contain any number of embedded forms, however only one form can be active. For switching between forms you use the following buttons: Previous form, Next form, Show form list.<br />
</em></p>
<p>The next picture shows the same region after clicking on the Minimize button (the Minimized state).</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/outlook-region-sample-minimized.png" alt="Minimized Outlook region" width="630" height="535" /></p>
<p>Finally, a double click on the left splitter collapses the region to a few pixels (the Hidden state).</p>
<p><img src="http://www.add-in-express.com/creating-addins-blog/wp-upload/outlook-region-hidden.png" alt="Hidden Outlook region" width="630" height="535" /></p>
<p>And the final note. <em>You can hide the headers for your regions</em> (we are often asked about that). Though, your end-users will not be able to move your forms between regions.</p>
<p>In my next post I will show you almost all types of regions. Stay tuned!</p>
<h3>See also</h3>
<ul class="list">
<li><a href="http://www.add-in-express.com/creating-addins-blog/2009/02/26/2009-outlook-forms-zero-visibility/">Outlook regions zero-visibility, part 1</a></li>
<li><a href="http://www.add-in-express.com/creating-addins-blog/2009/03/02/outlook-region-zero-visibility/">Outlook regions zero-visibility, part 2</a></li>
<li><a href="http://www.add-in-express.com/creating-addins-blog/2009/04/03/outlook-drag-drop-forms/">Outlook regions and drag-and-drop</a></li>
<li><a href="http://www.add-in-express.com/creating-addins-blog/2009/04/10/outlook-navigation-pane-customizing/">HowTo: Customize Navigation Pane in Outlook 2003 and 2007</a></li>
<li><a href="http://www.add-in-express.com/creating-addins-blog/2009/03/20/outlook-email-item-drag-drop/">HowTo: Get properties of an Outlook email item drag-and-dropped onto a .NET form</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/04/15/outlook-forms-regions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo: Customize Navigation Pane in Outlook 2003 and 2007</title>
		<link>http://www.add-in-express.com/creating-addins-blog/2009/04/10/outlook-navigation-pane-customizing/</link>
		<comments>http://www.add-in-express.com/creating-addins-blog/2009/04/10/outlook-navigation-pane-customizing/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 17:34:00 +0000</pubDate>
		<dc:creator>Dmitry Kostochko</dc:creator>
				<category><![CDATA[HowTo samples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.add-in-express.com/creating-addins-blog/?p=587</guid>
		<description><![CDATA[What is the Outlook Navigation pane? According to Microsoft, it is the column on the left side of the Outlook window that includes panes such as Shortcuts or Mail and the shortcuts or folders within each pane. The Navigation Pane was introduced in Outlook 2003 and enhanced in Outlook 2007. Let's see what a developer can do with the Navigation Pane...]]></description>
			<content:encoded><![CDATA[<p>What is the Outlook Navigation pane? According to Microsoft, it is the column on the left side of the Outlook window that includes panes such as Shortcuts or Mail and the shortcuts or folders within each pane. The Navigation Pane was introduced in Outlook 2003 and enhanced in Outlook 2007. Let&#8217;s see what a developer can do with the Navigation Pane.</p>
<p>Well, in Outlook 2003 the only thing that the developer can do is to switch the Navigation Pane on and off. Agree, it&#8217;s barely sufficient, but that&#8217;s the whole of the Outlook 2003 Object model capabilities available for the developer:</p>
<pre class="SrcCode"><code class="vb">
Private Sub ButtonVisible_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles ButtonVisible.Click
    If TryCast(ExplorerObj, Outlook._Explorer). _
    IsPaneVisible(Outlook.OlPane.olNavigationPane) Then
        TryCast(ExplorerObj, Outlook._Explorer).ShowPane( _
        Outlook.OlPane.olNavigationPane, False)
        ButtonVisible.Text = "Navigation Pane On"
    Else
        TryCast(ExplorerObj, Outlook._Explorer).ShowPane( _
        Outlook.OlPane.olNavigationPane, True)
        ButtonVisible.Text = "Navigation Pane Off"
    End If
End Sub
</code></pre>
<p>In this respect, the Outlook Object Model 2007 offers far more features. Besides the ability to minimize the Navigation pane programmatically, we can switch between navigation modules using the <a href="http://msdn.microsoft.com/en-us/library/bb147802.aspx" target="_blank">CurrentModule</a> property, manage the folder list in Favorite Folders, create your own groups in all navigation modules except for <a href="http://msdn.microsoft.com/en-us/library/bb176369.aspx" target="_blank">MailModule</a> module, populate custom <a href="http://msdn.microsoft.com/en-us/library/bb176373.aspx" target="_blank">NavigationGroup</a> using the <a href="http://msdn.microsoft.com/en-us/library/bb176424.aspx" target="_blank">NavigationFolders</a> collection.</p>
<p>I am not going to publish the whole code right here, you can download the C# sample and VB.NET sample using the links below. As to the notorious question &#8220;How to add a custom button to the bottom of the Navigation Pane?&#8221;, the answer is the same as before – there is no way to do it. Even the Outlook 2007 Object Model doesn&#8217;t allow this. Probably something will change in the next Microsoft Office version, let&#8217;s wait and hope :)</p>
<h3>You may also be interested in:</h3>
<p><a href="http://www.add-in-express.com/add-in-net/outlook-regions.php">Outlook customization: Reading pane, Outlook bar and To-Do bar</a><br />
<a href="http://www.add-in-express.com/creating-addins-blog/2009/02/26/2009-outlook-forms-zero-visibility/">Special features for Outlook plug-in development</a></p>
<h3>Available downloads:</h3>
<p><a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-navigation-pane-cs.zip">C# sample Outlook add-in for VS 2005</a><br />
<a href="http://www.add-in-express.com/files/howtos/blog/adx-ol-navigation-pane-vb.zip">VB.NET sample Outlook add-in for VS 2005</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.add-in-express.com/creating-addins-blog/2009/04/10/outlook-navigation-pane-customizing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
