Microsoft Office Tutorials and References
In Depth Information
Chart Examples
In addition to the clock chart, the workbook contains a text box that displays the time using the
NOW function, as shown in Figure 17-20. Normally hidden behind the analog clock, you can
display this text box by deselecting the Analog Clock check box. A simple VBA procedure attached
to the check box hides and unhides the chart, depending on the status of the check box.
Figure 17-20: Displaying a digital clock in a worksheet is much easier but not as fun to create.
The workbook with the animated clock example appears on the companion CD-ROM.
The filename is clock chart.xlsx .
When you examine the workbook, keep the following points in mind:
h The ChartObject, named ClockChart, covers up a range named DigitalClock, which is used
to display the time digitally.
h The two buttons on the worksheet are from the Forms group (Developer
Insert), and each has a VBA procedure assigned to it ( StartClock and StopClock ).
h Selecting the check box control executes a procedure named cbClockType_Click ,
which simply toggles the Visible property of the chart. When the chart is hidden, the
digital clock is revealed.
h The UpdateClock procedure uses the OnTime method of the Application object.
This method enables you to execute a procedure at a specific time. Before the
UpdateClock procedure ends, it sets up a new OnTime event that occurs in one
second. In other words, the UpdateClock procedure is called every second.
h The UpdateClock procedure inserts the following formula into the cell named
Inserting this formula causes the workbook to calculate, updating the clock.
Search JabSto ::

Custom Search