Manage Learn to apply best practices and optimize your operations.

An easier way to find values for Microsoft constants

Many people write code in Excel to get a message box to reveal the constant's value, but there is an easier way.

View member feedback to this tip.

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.

  1. Using Excel as an example, go to [Tools][Macro][Visual Basic Editor].

  2. In the Visual Basic editor, either press F2 or go to [View][Object Browser].

  3. 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.

MEMBER FEEDBACK TO THIS TIP

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.

—Joseph S.

******************************************

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.

—Cole S.

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.

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close