When using COM to control Microsoft Office applications from Lotus Notes, a common technique used to discover how to ask the application to do something (in Word or Excel for example) is to record a macro while you perform the action and then look at the macro code. The problem with this method is that, when you try to transfer the code to LotusScript, the VBA code makes heavy use of constants -- e.g., xlRight, xlCenter, or xlLeft for cell alignment in Excel. These constant names can be replaced with their corresponding numbers, if you know what they are.
Many people write code in Excel to get a message box to reveal the constant's value, but there is an easier way.
- Using Excel as an example, go to [Tools][Macro][Visual Basic Editor].
- In the Visual Basic editor, either press F2 or go to [View][Object Browser].
- Type the name of the constant in the search box and click on the binoculars to start the search.
The constant will be returned, and at the bottom of the screen will be its corresponding value in both hex and dec -- e.g., xlLeft is -4131 dec. You will find that any related constants are also displayed. This saves me a LOT of time.
Another easy way to find the Microsoft constant from within the Visual Basic Editor it to use the Immediate Window: From the menu, choose View -> Immediate Window. In the Immediate Window, typing "? xlLeft" without the quotes and pressing the Enter key will display the corresponding value. The question mark just tells the editor to print the value to the Immediate Window.
There's a much easier method of finding the underlying numeric constant value inside the VB Editor of MS Office tools like Excel. All you have to do is right click on the constant name; then, from the context menu, select Quick Info. A little pop-up will display showing the numeric value of the selected constant. I'm not sure what version of the VB Editor this feature became available, but I do know it works in Excel 2002.
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip exchange by member Melissa Snell. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.