Database Reference
In-Depth Information
Cells B12 and B13 at the end of the code segment turns on the macro print options to aid with
debugging and audit requirements for the code. Remember, these jobs can be run in a Windows
batch mode without a user interface. So, we need to be able to determine what really happened.
The line is duplicated because the first line turns the option back on, and the second line echoes
the command on the screen. It would not be visible without the second command.
The last line (cell B15) ends the macro definition.
14.3.8 Learn How to Make the Excel UserForm Execute
Learn how to make the Excel UserForm run
Now we have this neat GUI interface that is inside of an Excel workbook, but how do you use it? The
following VBA code segment will cause the UserForm1 to execute when the spreadsheet is opened. This
code is stored only in this workbook, so it is not visible to any other Excel workbook. This code is placed
into the “ThisWorkbook” area of the Excel workbook.
Figure 14.12: The VBA Macro “Workbook_open” with VBA Code to Load and Show a VBA
UserForm.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' My company name and code header here
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' Subroutine function:
''
'' Load and show the Excel User Form "UserForm1"
'' on the full screen
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' last update:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Workbook_Open()
Load UserForm1
UserForm1.Zoom = 100
UserForm1.Show
End Sub
Figure 14.13: Workbook_open VBA Subroutine to Open the UserForm1 GUI Shown in the
Excel IDE.
 
Search WWH ::




Custom Search