Calling on Word

Calling on Word

Microsoft Word exposes the WordBasic object. Through this object, you can execute WordBasic statements. The WordBasic statements and functions can be used as methods of the WordBasic object. Most WordBasic method names match the menu selection available in Word, and the parameters match the dialog items:

 'Declare form levelDim wd As ObjectSub CreateWordObject( )Set wd = CreateObject ("Word.Basic")wd.FileNewDefaultwd.FontSize 20wd.Insert "Hello, World"wd.FileSaveAs "Hello.Doc"wd.FileClose

If you are familiar with Microsoft Word, you know that each method name corresponds to the menu name concatenated by submenu option names, and the functionality is the same as in Word. You can also use the Word Macro recorder to create code and then copy that code to your Visual Basic application.


Share the Post: