Application Caption Microsoft Word VBA, C#, Vb.Net Example

Application Caption Microsoft Word VBA, C#, Vb.Net Example

Application

in Microsoft Word the Application object is referred to be the top most object which helps customizing or handle the Word Application. In this article we will change Application caption which looks like below with our own custom text:

If you notice the tile of the document has two parts:

  1. Name: this is the label which displays current document name in above screenshot it is labeled as “Document1”
  2. Caption: this is the caption which is default set to “Word”

In this example we will manipulate the Caption property of Application object using VSTO (Visual Studio Tools for Application) C# and VB.Net

Prerequisites

  1. Visual Studio 2015 or above having Microsoft Office for Developer Tool installed
  2. Create Excel Addin in C# or VB.Net code style (Visual Studio Tools for Office)
  3. Word 2010 or above
  4. Create a ribbon designer and put button

C# code example

change caption from “Word” to “VBAOVERALL

private void btnProtect_Click(object sender, RibbonControlEventArgs e)
{
	//Bind application reference
	wordApp.Application oApplication = Globals.ThisAddIn.Application;

	//Change caption
	oApplication.Caption = "VBAOVERALL";
}

VB.Net code example

Private Sub btnChangeCaption_Click(sender As Object, e As RibbonControlEventArgs) Handles btnChangeCaption.Click
	'Bind application reference
	Dim oApplication As word.Application
	oApplication = Globals.ThisAddIn.Application

	'Change caption
	oApplication.Caption = "VBAOVERALL"

End Sub

VBA code example

Public Sub ApplicationExample()
    'Create application variable
    Dim oApp As Application
    'Bind reference
    Set oApp = Word.Application
    'Change caption
    oApp.Caption = "VBAOVERALL"
End Sub

Output

Next >> Convert Text to Table Word VBA

Leave a Reply

Your email address will not be published. Required fields are marked *