Showing posts with label Accessing the Object Model of the Host Application. Show all posts
Showing posts with label Accessing the Object Model of the Host Application. Show all posts

Wednesday, October 5, 2011

Accessing the Object Model of the Host Application

To access the object model of the host application, use the Application field of the ThisAddIn class. This field returns an object that represents the current instance of the host application. The following table lists the type of the return value for the Application field in each add-in project.
Host application
Return value type
Microsoft Office Excel
Microsoft.Office.Interop.Excel.Application
Microsoft Office InfoPath
Microsoft.Office.Interop.InfoPath.Application
Microsoft Office Outlook
Microsoft.Office.Interop.Outlook.Application
Microsoft Office PowerPoint
Microsoft.Office.Interop.PowerPoint.Application
Microsoft Office Project
Microsoft.Office.Interop.MSProject.Application
Microsoft Office Visio
Microsoft.Office.Interop.Visio.Application
Microsoft Office Word
Microsoft.Office.Interop.Word.Application
The following code example shows how to use the Application field to create a new workbook in an add-in for Microsoft Office Excel. This example is intended to be run from the ThisAddIn class.
 
C#
Excel.Workbook newWorkbook = this.Application.Workbooks.Add(System.Type.Missing);
To do the same thing from outside the ThisAddIn class, use the Globals object to access the ThisAddIn class. For more information about the Globals object,
 
C#
Excel.Workbook newWorkbook = Globals.ThisAddIn.Application.Workbooks.Add(System.Type.Missing);

Featured Posts

Kali Linux Remote Desktop: Access GNOME from Windows Using Native RDP

  Kali Linux + GNOME 50 + GNOME Remote Desktop + Windows Remote Desktop (MSTSC) Getting a full GNOME desktop remotely on Kali Linux can be ...