In Word, you can automate frequently used tasks by creating and running macros or VBA script . A macro is a series of commands and instructions that you group together as a single command under a procedure or function to accomplish a task automatically. This can be enhanced to take code development to the next level by understanding Word object reference. In this article we will see major objects which can be referred in VBA environment to automate various Word tasks.
- Application: refers to Microsoft Word Application
- Document: refers to a word file which opens withing Word Application
- Page: area where user performs editing
- Paragraph: refers to text block within page
- Section: specific page layout and formatting options (such as line numbering, columns, or headers and footers) for different parts of a document. Word treats a document as a single section until you insert a section break.
- Header/Footer: populate common information like Date, Page Number, Brand name etc at the bottom and top of the page which repeats on each page
- Selection: refers to current selection in a document
- Range: specific selected text range
- Bookmarks: to identify specific area by unique name within document similar to Name ranges in Excel
- Page breaks: refers to various type of page breaks within a document
- Tables: a physical table to populate data in row/column manner.
- Comment: a sort flag which can be attached to specific word, paragraph
- Track changes: to track changes in a document done by various users
- Borders: refers to various borders like page border, object border, table border etc.
- Building Block: A building block is pre-built content, similar to autotext, that may contain text, images, and formatting
- Canvas: to draw a object on the page can be floating or inline
- Chart: similar to Excel, Word also provide chart insertion within document
- Dialog: refers to various inbuilt dialogs like open, saveAs, format etc.
- Styles: another rich object to determine style of a paragraph, text, line etc.
- Hyperlink: we can insert various hyperlinks in Word document
- Shape: similar to Excel in Word also we can play with shapes
- TaskPane: refers to a side window which is used to perform object specific tasks
- Find & Replace: very useful object when dealing with a large document
Above list is enough to automate a Word environment however, there are many more options which user can explore during automating the job, some of them can be trapped using macro recording feature.
In my next article I will start explaining each object in details following three different languages i.e. VBA, VB.NET and C#
Please leave your comments or queries under comment section also please do subscribe to out blogs to keep your self upto date.