Task Pane Demo Sample

This sample demonstrates how to create a custom task pane for Microsoft Office Word. The task pane contains a text box and a button. When the user types in the text box and clicks the button, the string in the text box is added to the beginning of the active document.

5 Star
5,822 times
Add to favorites
E-mail Twitter del.icio.us Digg Facebook
' Copyright © Microsoft Corporation.  All Rights Reserved.
' This code released under the terms of the 
' Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

Imports System
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Imports Word = Microsoft.Office.Interop.Word
Imports Office = Microsoft.Office.Core

Public Class SimpleControl

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

            If (Not insertTextBox.Text Is String.Empty) Then
                Dim document As Word.Document
                Dim range As Word.Range
                document = Globals.ThisAddIn.Application.ActiveDocument
                range = document.Range()
            End If
        Catch ex As COMException
        End Try

    End Sub
End Class