Making the Graph Page the Currently Displayed Window
We will use two SigmaPlot automation statements to determine the name of the page and then “open” it; i.e., bring it to the front. At the bottom of the macro add the following statements:
‘bring graph to front
Dim GraphPageName As String
The first statement GraphPageName=ActiveDocument.CurrentPageItem.Name gets the name of the CurrentPageItem in the ActiveDocument. A graph page is “current” if it is open and “topmost” (closest to you). In our case there is only one graph page so it needs to be open to be current – which it is. So this statement retrieves “Graph Page 1” as the graph name. Use Help to understand the automation statements. To do this highlight “CurrentPageItem”:
and press F1. This gives the help item on CurrentPageItem that explains:
Note the last comment about an error that can occur. See “Important Guidelines When Using Recorded Macros” for help with errors that can occur when macros are recorded. Also, Help mentions that the ActiveDocument property must still be used. Highlight “ActiveDocument” and press F1. Help then explains:
In our case there is only one notebook (Exponential Data Set.jnb) and it is open so it is the active notebook. If you click on Objects in the above help screen you will find that a notebook is part of the SigmaPlot application and this begins to describe the object hierarchy with application at the top, notebooks next, objects in notebooks (graph page in our case) next, and so on.
The second statement ActiveDocument.NotebookItems(GraphPageName). Open brings the graph page to the front. It does this as a side effect of opening the page. Since, in our case, the page is already open (if it was closed you would see its icon in the notebook but not see it displayed as a window) all it does is bring its window to the front.
Highlight “Open” and press F1. You find that the Open statement can be used to open notebooks (.jnb files) as well as notebook items (graph pages, worksheets, fit equations, etc.)
Save the modified macro and close its window. Run the macro by selecting Exponential Fit from the Macros dialog. When it is finished the graph window is displayed and is no longer hidden behind the worksheet.
If you are really persnickety about the looks of the displayed graph you will note that one set of symbols is highlighted and therefore looks funny. It is a simple procedure to un-highlight the symbols by hand by clicking outside the graph. We can emulate this in our macro as a quick-and-dirty procedure to un-highlight the symbols.
We simply add a statement that corresponds to a mouse click outside the graph page. The easy way to find out what that statement is is to copy the appropriate statement from a recorded macro and add this statement to our macro. When this is done the graph will look perfect.