Class Application (Word VBA)

The class Application represents the Microsoft Word application. The Application object includes properties and methods that return top-level objects. For example, the ActiveDocument property returns a Document object.

The main procedure of class Application is Activate

Set

To use a Application class variable it first needs to be instantiated, for example

Dim app as Application
Set app = Application.KeyBindings

Themes

Some procedures in this class have been grouped together in themes and are described on separate theme pages

Print with its procedures ActivePrinter, BackgroundPrintingStatus, PrintOut and PrintPreview
Name with its procedures AutoCaptions, Caption, LookupNameProperties, Name and UserName
DDE with its procedures DDEExecute, DDEInitiate, DDEPoke, DDERequest, DDETerminate and DDETerminateAll
Format with its procedures DefaultSaveFormat, FontNames, GetDefaultTheme, LandscapeFontNames, PortraitFontNames, RestrictLinkedStyles, SetDefaultTheme, ShowStylePreviews, SmartArtColors, SmartArtLayouts, SmartArtQuickStyles, SubstituteFont, UsableHeight, UsableWidth and Visible
Display/Show with its procedures DisplayAlerts, DisplayAutoCompleteTips, DisplayDocumentInformationPanel, DisplayRecentFiles, DisplayScreenTips, DisplayScrollBars, ShowAnimation, ShowClipboard, ShowMe, ShowStartupDialog and ShowVisualBasicEditor

Methods

This is the main method of the Application class

Activate - Activates the specified object.

Application.Activate

Other Methods

AddAddress - Adds an entry to the address book. Each entry has values for one or more tag IDs.

Dim strTagID() As String: strTagID() = 
Dim strValue() As String: strValue() =  
Application.AddAddress TagID:=strTagID(), Value:=strValue()

BuildKeyCode - Returns a unique number for the specified key combination.

Dim lngBuildKeyCode As Long
lngBuildKeyCode = BuildKeyCode(Arg1:=wdKey0)

CheckSpelling - Checks a string for spelling errors. Returns a Boolean to indicate whether the string contains spelling errors. True if the string has no spelling errors.

Dim strWord As String: strWord =  
Dim booCheckSpelling As Boolean
booCheckSpelling = CheckSpelling(Word:=strWord)

CompareDocuments - Compares two documents and returns a Document object that represents the document that contains the differences between the two documents, marked using tracked changes.

Dim docCompareDocuments As Document
Set docCompareDocuments = Application.CompareDocuments(OriginalDocument:=, RevisedDocument:=)

GetAddress - Returns an address from the default address book.

Dim strGetAddress As String
strGetAddress = Application.GetAddress()

GetSpellingSuggestions - Returns a SpellingSuggestions collection that represents the words suggested as spelling replacements for a given word.

Dim strWord As String: strWord =  
Dim sssGetSpellingSuggestions As SpellingSuggestions
Set sssGetSpellingSuggestions = GetSpellingSuggestions(Word:=strWord)

KeyString - Returns the key combination string for the specified keys (for example, CTRL+SHIFT+A).

Dim lngKeyCode As Long: lngKeyCode =  
Dim strKeyString As String
strKeyString = KeyString(KeyCode:=lngKeyCode)

MergeDocuments - Compares two documents and returns a Document object that represents the document that contains the differences between the two documents, marked using tracked changes.

Dim docMergeDocuments As Document
Set docMergeDocuments = Application.MergeDocuments(OriginalDocument:=, RevisedDocument:=)

Move - Positions a task window or the active document window.

Dim lngLeft As Long: lngLeft = 
Dim lngTop As Long: lngTop =  
Application.Move Left:=lngLeft, Top:=lngTop

OnTime - Starts a background timer that runs a macro at a specified time.

Dim dtWhen As Date: dtWhen = 
Dim strName As String: strName =  
Application.OnTime When:=dtWhen, Name:=strName

OrganizerCopy - Copies the specified AutoText entry, toolbar, style, or macro project item from the source document or template to the destination document or template.

Dim strSource As String: strSource = 
Dim strDestination As String: strDestination = 
Dim strName As String: strName =  
Application.OrganizerCopy Source:=strSource, Destination:=strDestination, Name:=strName, Object:=wdOrganizerObjectAutoText

OrganizerDelete - Deletes the specified style, AutoText entry, toolbar, or macro project item from a document or template.

Dim strSource As String: strSource = 
Dim strName As String: strName =  
Application.OrganizerDelete Source:=strSource, Name:=strName, Object:=wdOrganizerObjectAutoText

PixelsToPoints - Converts a measurement from pixels to points. Returns the converted measurement as a Single.

Dim sngPixelsToPoints As Single
sngPixelsToPoints = PixelsToPoints(Pixels:=)

PointsToPixels - Converts a measurement from points to pixels. Returns the converted measurement as a Single.

Dim sngPointsToPixels As Single
sngPointsToPixels = PointsToPixels(Points:=)

Quit - Quits Microsoft Word and optionally saves or routes the open documents.

Application.Quit

Resize - Sizes the Word application window or the specified task window.

Dim lngWidth As Long: lngWidth = 
Dim lngHeight As Long: lngHeight =  
Application.Resize Width:=lngWidth, Height:=lngHeight

Run - Runs a Visual Basic macro.

Dim strMacroName As String: strMacroName =  
Application.Run MacroName:=strMacroName

Properties

ActiveDocument returns a Document object that represents the active document (the document with the focus). If there are no documents open, an error occurs.

Dim docActiveDocument As Document
Set docActiveDocument = ActiveDocument

ActiveEncryptionSession returns a Long that represents the encryption session associated with the active document.

Dim lngActiveEncryptionSession As Long
lngActiveEncryptionSession = Application.ActiveEncryptionSession

ActiveProtectedViewWindow returns a ProtectedViewWindow object that represents the active Protected View window.

Dim pvwActiveProtectedViewWindow As ProtectedViewWindow
Set pvwActiveProtectedViewWindow = ActiveProtectedViewWindow

ActiveWindow returns a Window object that represents the active window (the window with the focus). If there are no windows open, an error occurs.

Dim wndActiveWindow As Window
Set wndActiveWindow = ActiveWindow

AddIns returns an AddIns collection that represents all available add-ins, regardless of whether they're currently loaded.

Dim aisAddIns As AddIns
Set aisAddIns = AddIns

ArbitraryXMLSupportAvailable returns a Boolean that represents whether Microsoft Word accepts custom XML schemas. True indicates that Word accepts custom XML schemas.

Dim booArbitraryXMLSupportAvailable As Boolean
booArbitraryXMLSupportAvailable = Application.ArbitraryXMLSupportAvailable

Assistance returns an Assistance object that represents the Microsoft Office Help Viewer.

Dim iaeAssistance As Office.IAssistance
Set iaeAssistance = Application.Assistance

AutoCorrect returns an AutoCorrect object that contains the current AutoCorrect options, entries, and exceptions.

Dim actAutoCorrect As AutoCorrect
Set actAutoCorrect = AutoCorrect

AutoCorrectEmail returns an AutoCorrect object that represents automatic corrections made to email messages.

Dim actAutoCorrectEmail As AutoCorrect
Set actAutoCorrectEmail = AutoCorrectEmail

AutomationSecurity returns or sets an MsoAutomationSecurity constant that represents the security setting Microsoft Word uses when programmatically opening files.

Application.AutomationSecurity =

BackgroundSavingStatus returns the number of files queued up to be saved in the background.

Dim lngBackgroundSavingStatus As Long
lngBackgroundSavingStatus = Application.BackgroundSavingStatus

Bibliography returns a Bibliography object that represents the bibliography references sources stored in Microsoft Word.

Dim bblBibliography As Bibliography
Set bblBibliography = Application.Bibliography

BrowseExtraFileTypes set this property to "text/html" to allow hyperlinked HTML files to be opened in Microsoft Word (instead of the default Internet browser).

Application.BrowseExtraFileTypes =

Browser returns a Browser object that represents the Select Browse Object tool on the vertical scroll bar.

Dim brwBrowser As Browser
Set brwBrowser = Application.Browser

Build returns the version and build number of the Word application.

Dim strBuild As String
strBuild = Application.Build

CapsLock true if the CAPS LOCK key is turned on.

Dim booCapsLock As Boolean
booCapsLock = Application.CapsLock

CaptionLabels returns a CaptionLabels collection that represents all the available caption labels.

Dim clsCaptionLabels As CaptionLabels
Set clsCaptionLabels = CaptionLabels

ChartDataPointTrack returns or sets a Boolean that specifies whether charts use cell-reference data-point tracking.

Application.ChartDataPointTrack = True

CheckLanguage true if Microsoft Word automatically detects the language you are using as you type.

Application.CheckLanguage = True

COMAddIns returns a reference to the COMAddIns collection that represents all the Component Object Model (COM) add-ins currently loaded in Microsoft Word.

Dim comsCOMAddIns As Office.COMAddIns
Set comsCOMAddIns = Application.COMAddIns

CommandBars returns a CommandBars collection that represents the menu bar and all the toolbars in Microsoft Word.

Dim cbsCommandBars As Office.CommandBars
Set cbsCommandBars = CommandBars

CustomDictionaries returns a Dictionaries object that represents the collection of active custom dictionaries.

Dim dctsCustomDictionaries As Dictionaries
Set dctsCustomDictionaries = CustomDictionaries

CustomizationContext returns or sets a Template or Document template that represents the template or document in which changes to menu bars, toolbars, and key bindings are stored. Read/write.

CustomizationContext =

DefaultLegalBlackline true for Microsoft Word to compare and merge documents using the Legal blackline option in the Compare and Merge Documents dialog box.

Application.DefaultLegalBlackline = True

DefaultTableSeparator returns or sets the single character used to separate text into cells when text is converted to a table.

Application.DefaultTableSeparator =

Dialogs returns a Dialogs collection that represents all the built-in dialog boxes in Word.

Dim dlgsDialogs As Dialogs
Set dlgsDialogs = Dialogs

Documents returns a Documents collection that represents all the open documents.

Dim docsDocuments As Documents
Set docsDocuments = Documents

DontResetInsertionPointProperties returns or sets a Boolean that represents whether Microsoft Word maintains the formatting properties of the text at that position of the Insertion Point after running other code.

Application.DontResetInsertionPointProperties = True

EmailOptions returns an EmailOptions object that represents the global preferences for email authoring.

Dim eosEmailOptions As EmailOptions
Set eosEmailOptions = Application.EmailOptions

EmailTemplate returns or sets a String that represents the document template to use when sending email messages.

Application.EmailTemplate =

EnableCancelKey returns or sets the way that Word handles CTRL+BREAK user interruptions.

Application.EnableCancelKey = wdCancelDisabled

FeatureInstall returns or sets how Microsoft Word handles calls to methods and properties that require features not yet installed.

Application.FeatureInstall =

FileConverters returns a FileConverters collection that represents all the file converters available to Microsoft Word.

Dim fcsFileConverters As FileConverters
Set fcsFileConverters = FileConverters

FileDialog returns a FileDialog object which represents a single instance of a file dialog box.

Dim fdgFileDialog As Office.FileDialog
Set fdgFileDialog = Application.FileDialog(FileDialogType:=msoFileDialogOpen)

FileValidation returns or sets how Word will validate files before opening them.

Application.FileValidation =

FindKey returns a KeyBinding object that represents the specified key combination.

Dim lngKeyCode As Long: lngKeyCode =  
Dim kbgFindKey As KeyBinding
Set kbgFindKey = FindKey(KeyCode:=lngKeyCode)

FocusInMailHeader true if the insertion point is in an email header field (the To: field, for example).

Dim booFocusInMailHeader As Boolean
booFocusInMailHeader = Application.FocusInMailHeader

HangulHanjaDictionaries returns a HangulHanjaConversionDictionaries collection that represents all the active custom conversion dictionaries.

Dim hhcsHangulHanjaDictionaries As HangulHanjaConversionDictionaries
Set hhcsHangulHanjaDictionaries = HangulHanjaDictionaries

Height returns or sets the height of the active document window in pixels.

Application.Height =

International returns information about the current country/region and international settings.

Dim varInternational As Variant
varInternational = Application.International(Index:=wd24HourClock)

IsObjectValid true if the specified variable that references an object is valid.

Dim booIsObjectValid As Boolean
booIsObjectValid = IsObjectValid(Object:=True)

IsSandboxed true if the application window is a Protected View window.

Dim booIsSandboxed As Boolean
booIsSandboxed = IsSandboxed

KeyBindings returns a KeyBindings collection that represents customized key assignments, which include a key code, a key category, and a command.

Dim kbsKeyBindings As KeyBindings
Set kbsKeyBindings = KeyBindings

KeysBoundTo returns a KeysBoundTo object that represents all the key combinations assigned to the specified item.

Dim strCommand As String: strCommand =  
Dim kbtKeysBoundTo As KeysBoundTo
Set kbtKeysBoundTo = KeysBoundTo(KeyCategory:=wdKeyCategoryAutoText, Command:=strCommand)

Language returns an MsoLanguageID constant that represents the language selected for the Microsoft Word user interface.

Dim mliLanguage As Office.MsoLanguageID
mliLanguage = Application.Language

Languages returns a Languages collection that represents the proofing languages listed in the Language dialog box.

Dim lngsLanguages As Languages
Set lngsLanguages = Languages

LanguageSettings returns a LanguageSettings object, which contains information about the language settings in Microsoft Word.

Dim lssLanguageSettings As Office.LanguageSettings
Set lssLanguageSettings = LanguageSettings

Left returns or sets a Long that represents the horizontal position of the active document, measured in points.

Application.Left =

ListGalleries returns a ListGalleries collection that represents the three list template galleries.

Dim lgsListGalleries As ListGalleries
Set lgsListGalleries = ListGalleries

MacroContainer returns a Template or Document template that represents the template or document in which the module that contains the running procedure is stored.

Dim docMacroContainer As Document
Set docMacroContainer = MacroContainer

MailingLabel returns a MailingLabel object that represents a mailing label.

Dim mllMailingLabel As MailingLabel
Set mllMailingLabel = Application.MailingLabel

MailMessage returns a MailMessage object that represents the active email message.

Dim mmeMailMessage As MailMessage
Set mmeMailMessage = Application.MailMessage

MailSystem returns the mail system (or systems) installed on the host computer.

Dim wmsMailSystem As WdMailSystem
wmsMailSystem = Application.MailSystem

MAPIAvailable true if MAPI is installed.

Dim booMAPIAvailable As Boolean
booMAPIAvailable = Application.MAPIAvailable

MathCoprocessorAvailable true if a math coprocessor is installed and available to Microsoft Word.

Dim booMathCoprocessorAvailable As Boolean
booMathCoprocessorAvailable = Application.MathCoprocessorAvailable

MouseAvailable true if there is a mouse available for the system.

Dim booMouseAvailable As Boolean
booMouseAvailable = Application.MouseAvailable

NewDocument

Dim nfeNewDocument As Office.NewFile
Set nfeNewDocument = Application.NewDocument

NormalTemplate returns a Template object that represents the Normal template.

Dim tmpNormalTemplate As Template
Set tmpNormalTemplate = NormalTemplate

NumLock returns the state of the NUM LOCK key. True if the keys on the numeric keypad insert numbers, False if the keys move the insertion point.

Dim booNumLock As Boolean
booNumLock = Application.NumLock

OMathAutoCorrect returns an OMathAutoCorrect object that represents the auto correct entries for equations.

Dim omaOMathAutoCorrect As OMathAutoCorrect
Set omaOMathAutoCorrect = Application.OMathAutoCorrect

OpenAttachmentsInFullScreen returns or sets a Boolean that represents whether Microsoft Word opens email attachments in Reading mode.

Application.OpenAttachmentsInFullScreen = True

Options returns an Options object that represents application settings in Microsoft Word.

Dim optsOptions As Options
Set optsOptions = Options

Parent returns an object that represents the parent object of the specified Application object.

Dim objParent As Object
Set objParent = Parent

Path returns the disk or Web path to the specified object.

Dim strPath As String
strPath = Application.Path

PathSeparator returns the character used to separate folder names. This property returns a backslash ().

Dim strPathSeparator As String
strPathSeparator = Application.PathSeparator

PickerDialog returns a PickerDialog object that provides the functionality to select people or data in a dialog box.

Dim pdgPickerDialog As Office.PickerDialog
Set pdgPickerDialog = Application.PickerDialog

ProtectedViewWindows returns a ProtectedViewWindows collection that represents all Protected View windows.

Dim pvwsProtectedViewWindows As ProtectedViewWindows
Set pvwsProtectedViewWindows = ProtectedViewWindows

RecentFiles returns a RecentFiles collection that represents the most recently accessed files.

Dim rfsRecentFiles As RecentFiles
Set rfsRecentFiles = RecentFiles

ScreenUpdating true if screen updating is turned on.

Application.ScreenUpdating = True

Selection returns the Selection object that represents a selected range or the insertion point.

Dim slcSelection As Selection
Set slcSelection = Selection

SpecialMode true if Microsoft Word is in a special mode (for example, CopyText mode, or MoveText mode).

Dim booSpecialMode As Boolean
booSpecialMode = Application.SpecialMode

StartupPath returns or sets the complete path of the startup folder, excluding the final separator.

Application.StartupPath =

StatusBar this property is no longer supported in Microsoft Word Visual Basic for Applications.

StatusBar =

SynonymInfo returns a SynonymInfo object that contains information from the thesaurus on synonyms, antonyms, or related words and expressions for the specified word or phrase.

Dim strWord As String: strWord =  
Dim sioSynonymInfo As SynonymInfo
Set sioSynonymInfo = SynonymInfo(Word:=strWord)

System returns a System object, which can be used to return system-related information and perform system-related tasks.

Dim sysSystem As System
Set sysSystem = System

TaskPanes returns a TaskPanes collection that represents the most commonly performed tasks in Microsoft Word.

Dim tpsTaskPanes As TaskPanes
Set tpsTaskPanes = Application.TaskPanes

Tasks returns a Tasks collection that represents all the applications that are running.

Dim tsksTasks As Tasks
Set tsksTasks = Tasks

Templates returns a Templates collection that represents all the available templates—global templates and those attached to open documents.

Dim tmpsTemplates As Templates
Set tmpsTemplates = Templates

Top returns or sets the vertical position of the active document.

Application.Top =

UndoRecord returns an UndoRecord object that provides a custom entry point into the undo stack.

Dim urdUndoRecord As UndoRecord
Set urdUndoRecord = Application.UndoRecord

UserAddress returns or sets the user's mailing address.

Application.UserAddress =

UserControl true if the document or application was created or opened by the user.

Dim booUserControl As Boolean
booUserControl = Application.UserControl

UserInitials returns or sets the user's initials, which Microsoft Word uses to construct comment marks.

Application.UserInitials =

VBE returns a VBE object that represents the Visual Basic Editor.

Dim vbeVBE As VBIDE.VBE
Set vbeVBE = VBE

Version returns the Microsoft Word version number.

Dim strVersion As String
strVersion = Application.Version

Width returns or sets the width of the application window, in points.

Application.Width =

Windows returns a Windows collection that represents all document windows.

Dim wndsWindows As Windows
Set wndsWindows = Windows

WindowState returns or sets the state of the specified document window or task window.

Application.WindowState = wdWindowStateMaximize

XMLNamespaces returns an collection that represents the XML schemas in the Schema Library.

Dim xmlsXMLNamespaces As XMLNamespaces
Set xmlsXMLNamespaces = Application.XMLNamespaces