G
Guest
Excel 2007. I have code that worked for years with Excel 2003 and now fails
regularly (but not always). I get the following error:Run time error '1004'
Unable to set the Enabled property of the OLEObject class
The error occurs on the first and any of the subsequent lines below the
asterisks in the following code. Someone had suggested fully qualifying the
references, which I did, but the problem persists. Thanks for ANY help you
may provide. God bless.
Private Sub Workbook_Open()
'GoTo tend
With ThisWorkbook
.Sheets("Main Menu").Activate
.Sheets("Main Menu").ScrollArea = "E7"
'Disable all buttons until initialization is complete.
'Make all sheets except Main invisible until init complete
.Sheets("Income Statements").Visible = False
.Sheets("Detail Reports").Visible = False
.Sheets("Budgets").Visible = False
.Sheets("Payroll Compare").Visible = False
.Sheets("Payroll ACH").Visible = False
.Sheets("Main Menu").IncomeStatements.Enabled = False
.Sheets("Main Menu").DetailReports.Enabled = False
.Sheets("Main Menu").Budgets.Enabled = False
.Sheets("Main Menu").PayrollCompare.Enabled = False
.Sheets("Main Menu").PayrollACH.Enabled = False
.Sheets("Main Menu").Setup.Enabled = False
.Sheets("Main Menu").ExitButton.Enabled = False
'Open status form and initialize completion boxes
StartupStatus.CheckBox1.Value = False
StartupStatus.CheckBox2.Value = False
StartupStatus.CheckBox3.Value = False
StartupStatus.Show 0
'Check to see if Express ClickYes is Running
If Not fIsProcessRunning("C:\Program Files\Express
ClickYes\ClickYes.exe") Then
If Dir("C:\Program Files\Express ClickYes\ClickYes.exe") = "" Then
MsgBox "Express ClickYes is not installed on your system." +
Chr(10) + "This will affect sending email from the switchboard." + Chr(10) +
"Contact your system administrator to have ClickYes installed.",
vbInformation, "Express ClickYes Not Installed"
Else
Shell ("C:\Program Files\Express ClickYes\ClickYes.exe")
End If
End If
StartupStatus.CheckBox1.Value = True
Application.ScreenUpdating = False
.Sheets("Contacts").Activate
Call GetAllAddresses
StartupStatus.CheckBox2.Value = True
.Sheets("Main Menu").Activate
.Sheets("Budgets").OtherRecipient.ListFillRange = "Contacts!A3:A" +
Trim(ThisWorkbook.Worksheets("Contacts").Cells(1, 1))
.Sheets("Income Statements").OtherRecipient.ListFillRange =
"Contacts!A3:A" + Trim(ThisWorkbook.Worksheets("Contacts").Cells(1, 1))
.Sheets("Detail Reports").OtherRecipient.ListFillRange = "Contacts!A3:A"
+ Trim(ThisWorkbook.Worksheets("Contacts").Cells(1, 1))
'Update the Project Definitions sheet
Call Update_Projects_Information
StartupStatus.CheckBox3.Value = True
'Make sure only one sheet is created in new workbooks
Application.SheetsInNewWorkbook = 1
'Delay before removing status form
Call WaitIt(2)
StartupStatus.Hide
'Enable all buttons
'Make all sheets visible
.Sheets("Income Statements").Visible = True
.Sheets("Detail Reports").Visible = True
.Sheets("Budgets").Visible = True
'Only allow privileged users to access payroll functions
If PrivUser(Environ("UserName")) Then
**********************************************************
.Sheets("Main Menu").PayrollCompare.Enabled = True
.Sheets("Main Menu").PayrollACH.Enabled = True
.Sheets("Payroll Compare").Visible = True
.Sheets("Payroll ACH").Visible = True
Else
.Sheets("Main Menu").PayrollCompare.Enabled = False
.Sheets("Main Menu").PayrollACH.Enabled = False
.Sheets("Payroll Compare").Visible = False
.Sheets("Payroll ACH").Visible = False
End If
.Sheets("Main Menu").IncomeStatements.Enabled = True
.Sheets("Main Menu").DetailReports.Enabled = True
.Sheets("Main Menu").Budgets.Enabled = True
.Sheets("Main Menu").Setup.Enabled = True
.Sheets("Main Menu").ExitButton.Enabled = True
Application.ScreenUpdating = True
End With
tend:
End Sub
regularly (but not always). I get the following error:Run time error '1004'
Unable to set the Enabled property of the OLEObject class
The error occurs on the first and any of the subsequent lines below the
asterisks in the following code. Someone had suggested fully qualifying the
references, which I did, but the problem persists. Thanks for ANY help you
may provide. God bless.
Private Sub Workbook_Open()
'GoTo tend
With ThisWorkbook
.Sheets("Main Menu").Activate
.Sheets("Main Menu").ScrollArea = "E7"
'Disable all buttons until initialization is complete.
'Make all sheets except Main invisible until init complete
.Sheets("Income Statements").Visible = False
.Sheets("Detail Reports").Visible = False
.Sheets("Budgets").Visible = False
.Sheets("Payroll Compare").Visible = False
.Sheets("Payroll ACH").Visible = False
.Sheets("Main Menu").IncomeStatements.Enabled = False
.Sheets("Main Menu").DetailReports.Enabled = False
.Sheets("Main Menu").Budgets.Enabled = False
.Sheets("Main Menu").PayrollCompare.Enabled = False
.Sheets("Main Menu").PayrollACH.Enabled = False
.Sheets("Main Menu").Setup.Enabled = False
.Sheets("Main Menu").ExitButton.Enabled = False
'Open status form and initialize completion boxes
StartupStatus.CheckBox1.Value = False
StartupStatus.CheckBox2.Value = False
StartupStatus.CheckBox3.Value = False
StartupStatus.Show 0
'Check to see if Express ClickYes is Running
If Not fIsProcessRunning("C:\Program Files\Express
ClickYes\ClickYes.exe") Then
If Dir("C:\Program Files\Express ClickYes\ClickYes.exe") = "" Then
MsgBox "Express ClickYes is not installed on your system." +
Chr(10) + "This will affect sending email from the switchboard." + Chr(10) +
"Contact your system administrator to have ClickYes installed.",
vbInformation, "Express ClickYes Not Installed"
Else
Shell ("C:\Program Files\Express ClickYes\ClickYes.exe")
End If
End If
StartupStatus.CheckBox1.Value = True
Application.ScreenUpdating = False
.Sheets("Contacts").Activate
Call GetAllAddresses
StartupStatus.CheckBox2.Value = True
.Sheets("Main Menu").Activate
.Sheets("Budgets").OtherRecipient.ListFillRange = "Contacts!A3:A" +
Trim(ThisWorkbook.Worksheets("Contacts").Cells(1, 1))
.Sheets("Income Statements").OtherRecipient.ListFillRange =
"Contacts!A3:A" + Trim(ThisWorkbook.Worksheets("Contacts").Cells(1, 1))
.Sheets("Detail Reports").OtherRecipient.ListFillRange = "Contacts!A3:A"
+ Trim(ThisWorkbook.Worksheets("Contacts").Cells(1, 1))
'Update the Project Definitions sheet
Call Update_Projects_Information
StartupStatus.CheckBox3.Value = True
'Make sure only one sheet is created in new workbooks
Application.SheetsInNewWorkbook = 1
'Delay before removing status form
Call WaitIt(2)
StartupStatus.Hide
'Enable all buttons
'Make all sheets visible
.Sheets("Income Statements").Visible = True
.Sheets("Detail Reports").Visible = True
.Sheets("Budgets").Visible = True
'Only allow privileged users to access payroll functions
If PrivUser(Environ("UserName")) Then
**********************************************************
.Sheets("Main Menu").PayrollCompare.Enabled = True
.Sheets("Main Menu").PayrollACH.Enabled = True
.Sheets("Payroll Compare").Visible = True
.Sheets("Payroll ACH").Visible = True
Else
.Sheets("Main Menu").PayrollCompare.Enabled = False
.Sheets("Main Menu").PayrollACH.Enabled = False
.Sheets("Payroll Compare").Visible = False
.Sheets("Payroll ACH").Visible = False
End If
.Sheets("Main Menu").IncomeStatements.Enabled = True
.Sheets("Main Menu").DetailReports.Enabled = True
.Sheets("Main Menu").Budgets.Enabled = True
.Sheets("Main Menu").Setup.Enabled = True
.Sheets("Main Menu").ExitButton.Enabled = True
Application.ScreenUpdating = True
End With
tend:
End Sub