Pass Top Down Concepts

Before going too far, you need to decide the level at which to locate the event procedures that you will need. Whatever event procedures you choose to develop, it is likely that they could be at the worksheet level, the workbook level, or the application level. Use workbook procedures because they add the flexibility of maintaining multiple diagrams, one in each worksheet of the workbook, and are slightly easier to implement than application-level events. The major downside, of course, is that the code and the data will reside in the same workbook. Of course, now that the event procedures will be at the workbook level, they will be triggered for every worksheet in the workbook, whether that sheet contains a wiring diagram or not. Hence, you need to ensure that the event procedures operate on only those worksheets that contain a wiring diagram, and leave untouched any worksheets used for other purposes. So, you need to somehow tag each worksheet that contains a wiring diagram.

It would appear that you need just one event procedure, Workbook_SheetChange, which goes into the Workbook's code module:

Private Sub Workbook_SheetChange( _

ByVal sh As Object, ByVal Target As Range) If Not TypeOf sh Is Worksheet Then Exit Sub

If Not (sh.Range(cWSWiringTagAddr).Value = cWSWiringTagID) Then _ Exit Sub '<<<<<

End Sub

Note that as of now, you haven't figured out how the change in a cell will translate into an action, and if so, whether it is adding a new connection, deleting an existing connection, or changing an existing connection. However, there's no need to address this quite yet. You'll do it later.

The major non-event procedure seems to be just the one that will create the initial setup. This requires filling in all the wiring codes in the m/nnn format in the correct locations and setting the font color to light gray. This procedure should also warn the client if the worksheet is not empty. Finally, it should add the tag to identify this worksheet as containing a wiring diagram. The following code goes into a standard module:

0 0

Post a comment