Thursday, August 8, 2013

My Take on the Immediate Window

The Immediate Window in the Microsoft Visual Basic Interface is a very handy thing indeed. But most of the documentation for the Immediate Window only covers how to make use of it in Debug Mode.
Lately, I've been using it to peek and poke at the inner workings of my files. There are times I like to have very precise control of element positioning; and, the application's interface only lets me eyeball it with the mouse. There are times I need to do things that the interface doesn't offer. For example: try filling a cell in MS Excel (2007) with a 3 stop asymmetrical gradient. The Immediate Window is your command line interface.
To see what I'm talking about, try this:
  • Launch MS Excel.
  • Launch the Visual Basic editor.
  • In the Immediate Window, enter the following:
?Selection.Address
  • The value of the Address property will be returned.
$A$1
This is a quick way to find the value of a property once, when you don't need to watch it change over time.
Granted our example is pretty insipid. But, what if you wanted to find the Left property of a Chart's PlotArea?
?ActiveChart.PlotArea.Left

Now that you know how many points the PlotArea is from the ChartArea's Left, you can set it to some other value.
ActiveChart.PlotArea.Left=36

If you are unsure where to start you can always type:
Application.

IntelliSense will offer some help after that.

No comments:

Post a Comment