LordDragon
10-18-2015, 10:14 PM
Greetings,
I was having problems with my workbook opening, so I moved most of the code that was trying to load during the Workbook_Open procesure to another sub and then tried to call it using Application.OnTime.
Private Sub Workbook_Open()
'Sets the password for each Worksheet, but still allows the code to work.
Dim wkSheet As Worksheet
For Each wkSheet In Worksheets
wkSheet.Protect "Password", UserInterfaceOnly:=True
Next wkSheet
'Forces the Workbook to open on the Instructions page.
Application.Goto Sheets("Instructions").Range("A1"), True
myTime = Now() + TimeValue("00:00:05")
Application.OnTime Earliesttime:=myTime, Procedure:="SetSystemSelectionBoxes", Schedule:=True
The Application.OnTime thing seems to be working fine, but instead of running the called sub, it gives me a notice that the sub either doesn't exist, or that macros are disabled.
I know macros are not disabled because I'm not getting the "Enable Content" warning, and it's running this one.
I have never used the Application.OnTime thing before, so I found some examples and modified them to what I needed. I'm not positive I did that correctly though.
Here is the code I'm attempting to call.
Private Sub SetSystemSelectionBoxes()
'Sets the options for the drop boxes on the System Selection sheet.
With Worksheets("System Selection").VoltageBox
.AddItem "110V"
.AddItem "220V"
End With
With Worksheets("System Selection").UnitsBox
.AddItem "Imperial"
.AddItem "Metric"
.AddItem "Mixed"
End With
With Worksheets("System Selection").TorqueBox
.AddItem "Electric"
.AddItem "Hydraulic"
End With
With Worksheets("System Selection").AutoDrillerBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").CasingBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").ChokeBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").EDRBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").ePVTBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").ESRBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").FlowBox
.AddItem "Yes"
.AddItem "No"
End With
With Worksheets("System Selection").GABox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").HGasBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").PRDBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").PVTBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").ProbeBox
.AddItem "Radar"
.AddItem "Mud Probe"
.AddItem "Both"
End With
With Worksheets("System Selection").SideKickBox
.AddItem "Yes"
.AddItem "No"
End With
With Worksheets("System Selection").UJBBox
.AddItem "Yes"
.AddItem "No"
End With
With Worksheets("System Selection").WorkstationsBox
.AddItem "No"
.AddItem "Yes"
End With
End Sub
Any help would be appreciated.
I was having problems with my workbook opening, so I moved most of the code that was trying to load during the Workbook_Open procesure to another sub and then tried to call it using Application.OnTime.
Private Sub Workbook_Open()
'Sets the password for each Worksheet, but still allows the code to work.
Dim wkSheet As Worksheet
For Each wkSheet In Worksheets
wkSheet.Protect "Password", UserInterfaceOnly:=True
Next wkSheet
'Forces the Workbook to open on the Instructions page.
Application.Goto Sheets("Instructions").Range("A1"), True
myTime = Now() + TimeValue("00:00:05")
Application.OnTime Earliesttime:=myTime, Procedure:="SetSystemSelectionBoxes", Schedule:=True
The Application.OnTime thing seems to be working fine, but instead of running the called sub, it gives me a notice that the sub either doesn't exist, or that macros are disabled.
I know macros are not disabled because I'm not getting the "Enable Content" warning, and it's running this one.
I have never used the Application.OnTime thing before, so I found some examples and modified them to what I needed. I'm not positive I did that correctly though.
Here is the code I'm attempting to call.
Private Sub SetSystemSelectionBoxes()
'Sets the options for the drop boxes on the System Selection sheet.
With Worksheets("System Selection").VoltageBox
.AddItem "110V"
.AddItem "220V"
End With
With Worksheets("System Selection").UnitsBox
.AddItem "Imperial"
.AddItem "Metric"
.AddItem "Mixed"
End With
With Worksheets("System Selection").TorqueBox
.AddItem "Electric"
.AddItem "Hydraulic"
End With
With Worksheets("System Selection").AutoDrillerBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").CasingBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").ChokeBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").EDRBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").ePVTBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").ESRBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").FlowBox
.AddItem "Yes"
.AddItem "No"
End With
With Worksheets("System Selection").GABox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").HGasBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").PRDBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").PVTBox
.AddItem "No"
.AddItem "Yes"
End With
With Worksheets("System Selection").ProbeBox
.AddItem "Radar"
.AddItem "Mud Probe"
.AddItem "Both"
End With
With Worksheets("System Selection").SideKickBox
.AddItem "Yes"
.AddItem "No"
End With
With Worksheets("System Selection").UJBBox
.AddItem "Yes"
.AddItem "No"
End With
With Worksheets("System Selection").WorkstationsBox
.AddItem "No"
.AddItem "Yes"
End With
End Sub
Any help would be appreciated.