| VBA - The Word Working Partner | |||||||||||||||||||||||
| The AboutVBA.DOC Code Sample | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
A more "VBA OOP" way to do things like this would be to use events that are triggered by methods of the Application or Document objects rather than just by a magic procedure that is in a particular place with a particular name. While your Word application has many objects with events that you can use (like the Document object and the Open event will trigger the Document_Open procedure), you can also add your own from the VBA Toolbox. Initially, let's write a VBA program to automate Word's own capabilities. It's pretty easy to add WordArt to your document without a VBA program. To do this manually, make sure that the WordArt toolbar is visible. Then select the text that you want to be displayed in WordArt, click the Insert WordArt button, select the style of WordArt, the font you want to use and the font size, select bold and italic if you want them, and finally position the WordArt on the page where you want it. Whew! Suppose, however, that in your job you frequently need to simply add a line of WordArt to the current paragraph right where the cursor happens to be using the text in the current line as the source. And the size, font, and style are always the same. You can code a quick VBA program to do this at the click of a button:
|
|||||||||||||||||||||||



