shell_l_d
07-08-2010, 05:05 PM
Having problems between different versions of Excel (& Windows)...
My spreadsheet has: 7 x worksheets
On Sheet1 ("Update") it has these:
2 x DTPickers shows: =EMBED("MSComCtl2.DTPicker.2","")
1 x combo box shows: =EMBED("Forms.ComboBox.1","")
2 x buttons shows nothing for formula - both call macros/procedures
Purpose: extracts data from a database (ADODB), puts results in few worksheets, creates tables, formatting, extra columns with calcs.
I can run the spreadsheet on my pc with Excel2007 (Win7), others can & others cant. Also fails on Excel2010 (WinVista), same errors as an Excel 2007 (WinVista) user. So seems to be working for Excel 2007 + Win7, but so far failing for (some/all?) Excel 2007/2010 + Vista.
Fails for Worksheets("Update") .Select & .Range("....") & on combobox code.
I can see the worksheet/ranges/combobox all exist & are named properly.
Error '32809 Application-defined or object-defined error' occurred in ThisWorkbook.Workbook_Open at line 15. ... same for lines 16 to 23.
Sub Workbook_Open()
' For Error Reporting
Dim sErrorDescription As String
Const sProcSig As String = MODULE_NAME & "Workbook_Open"
'On Error Resume Next
1 On Error GoTo Error_In_WorkbookOpen
2 With ActiveWorkbook
'Name cells for 'LAST UPDATE STATISTICS'
3 .Names.Add Name:="StartDate", RefersTo:="=Update!$E$5"
4 .Names.Add Name:="EndDate", RefersTo:="=Update!$E$8"
5 .Names.Add Name:="FilterField", RefersTo:="=Update!$E$11"
6 .Names.Add Name:="FilterFieldIndex", RefersTo:="=Update!$E$12"
7 .Names.Add Name:="LastUpdated", RefersTo:="=Update!$E$14"
8 .Names.Add Name:="UpdateStatus", RefersTo:="=Update!$E$15"
'Name cells for 'VB Libraries Info'
9 .Names.Add Name:="NumFoundLibs", RefersTo:="=Update!$E$20"
10 .Names.Add Name:="NumMissingLibs", RefersTo:="=Update!$E$21"
11 .Names.Add Name:="NumBrokenLibs", RefersTo:="=Update!$E$22"
' Clear values for 'VB Libraries Info' on 'Update' worksheet
12 Call ClearVbReferences
13 End With
14 With Worksheets("Update")
' Date/Time Format
15 .Range("StartDate").NumberFormat = "dd mmm yyyy"
16 .Range("EndDate").NumberFormat = "dd mmm yyyy"
17 .Range("LastUpdated").NumberFormat = "dd mmm yyyy"
' Fill combo box
18 .cbFilterField.Clear
19 .cbFilterField.AddItem ("CallTime")
20 .cbFilterField.AddItem ("TechComp")
21 .cbFilterField.AddItem ("CloseDate")
22 .cbFilterField.AddItem ("Calc Compl Date")
' Set default value
23 .cbFilterField.ListIndex = 0
24 End With
25 Call FixDTPickers
' ===== Exit Handler =====
Exit_WorkbookOpen:
26 Application.ScreenUpdating = True
27 Exit Sub
' ===== ERROR HANDLER =====
Error_In_WorkbookOpen:
28 With Err
29 sErrorDescription = "Error '" & .Number & " " & _
.Description & "' occurred in " & sProcSig & _
IIf(Erl <> 0, " at line " & CStr(Erl) & ".", ".")
30 End With
31 Select Case MsgBox(sErrorDescription, vbAbortRetryIgnore, "Error in " & sProcSig)
Case vbRetry
32 Resume
33 Case vbIgnore
34 Resume Next
35 Case Else
36 Resume Exit_WorkbookOpen
37 End
38 End Select
End Sub
Errors at line 12 > goes to Error Handler > fails at line 112 with:
Run-time error '32809'
Application-defined or object-defined error
Public Sub DataExtract()
...[more code]...
' Set 'last updated' statistics (dates)
4 Application.StatusBar = False
5 Application.ScreenUpdating = False
6 With ActiveWorkbook.Worksheets("Update")
' Obtain the start & end dates from the DTPickers
' this may cause errors... consider late binding of DTPickers
7 On Error Resume Next
8 dteStartDate = Format(.DTPickerStart, "yyyy-mm-dd")
9 dteEndDate = Format(.DTPickerEnd, "yyyy-mm-dd")
10 filterField = .cbFilterField.ListIndex
11 On Error GoTo Error_In_DataExtract
12 .Select
13 .Range("StartDate").Value = dteStartDate
14 .Range("EndDate").Value = dteEndDate
15 .Range("FilterField").Value = .cbFilterField.Value
16 .Range("FilterFieldIndex").Value = filterField
17 .Range("LastUpdated").Value = Date
18 .Range("UpdateStatus").Value = "Started"
19 End With
...[more code]...
' ===== ERROR HANDLER =====
Error_In_DataExtract:
'On Error Resume Next
110 Application.StatusBar = "Error occurred..."
111 With ActiveWorkbook.Worksheets("Update")
112 .Select
113 .Range("UpdateStatus").Value = "Failed"
114 End With
...[more code]...
Been testing with:
Excel 2007 with Vista / Win7
Excel 2010 with Vista
In Excel 2010: I deleted the 2 buttons from the "Update" worksheet & saved, closed, re-opened the spreadsheet to see if fixes problem. Problem still exists.
However... when I try to delete the combo box by selecting Design Mode > click combo box > Delete, it will crash excel. Will have to haven't tried removing the combo box using Excel 2007... anyhow just trying to pinpoint what object on the "Update" worksheet could be causing the errors/problems.
It would be so much easier if MS Office versions were multi-compatible... doh...
Any ideas please?
My spreadsheet has: 7 x worksheets
On Sheet1 ("Update") it has these:
2 x DTPickers shows: =EMBED("MSComCtl2.DTPicker.2","")
1 x combo box shows: =EMBED("Forms.ComboBox.1","")
2 x buttons shows nothing for formula - both call macros/procedures
Purpose: extracts data from a database (ADODB), puts results in few worksheets, creates tables, formatting, extra columns with calcs.
I can run the spreadsheet on my pc with Excel2007 (Win7), others can & others cant. Also fails on Excel2010 (WinVista), same errors as an Excel 2007 (WinVista) user. So seems to be working for Excel 2007 + Win7, but so far failing for (some/all?) Excel 2007/2010 + Vista.
Fails for Worksheets("Update") .Select & .Range("....") & on combobox code.
I can see the worksheet/ranges/combobox all exist & are named properly.
Error '32809 Application-defined or object-defined error' occurred in ThisWorkbook.Workbook_Open at line 15. ... same for lines 16 to 23.
Sub Workbook_Open()
' For Error Reporting
Dim sErrorDescription As String
Const sProcSig As String = MODULE_NAME & "Workbook_Open"
'On Error Resume Next
1 On Error GoTo Error_In_WorkbookOpen
2 With ActiveWorkbook
'Name cells for 'LAST UPDATE STATISTICS'
3 .Names.Add Name:="StartDate", RefersTo:="=Update!$E$5"
4 .Names.Add Name:="EndDate", RefersTo:="=Update!$E$8"
5 .Names.Add Name:="FilterField", RefersTo:="=Update!$E$11"
6 .Names.Add Name:="FilterFieldIndex", RefersTo:="=Update!$E$12"
7 .Names.Add Name:="LastUpdated", RefersTo:="=Update!$E$14"
8 .Names.Add Name:="UpdateStatus", RefersTo:="=Update!$E$15"
'Name cells for 'VB Libraries Info'
9 .Names.Add Name:="NumFoundLibs", RefersTo:="=Update!$E$20"
10 .Names.Add Name:="NumMissingLibs", RefersTo:="=Update!$E$21"
11 .Names.Add Name:="NumBrokenLibs", RefersTo:="=Update!$E$22"
' Clear values for 'VB Libraries Info' on 'Update' worksheet
12 Call ClearVbReferences
13 End With
14 With Worksheets("Update")
' Date/Time Format
15 .Range("StartDate").NumberFormat = "dd mmm yyyy"
16 .Range("EndDate").NumberFormat = "dd mmm yyyy"
17 .Range("LastUpdated").NumberFormat = "dd mmm yyyy"
' Fill combo box
18 .cbFilterField.Clear
19 .cbFilterField.AddItem ("CallTime")
20 .cbFilterField.AddItem ("TechComp")
21 .cbFilterField.AddItem ("CloseDate")
22 .cbFilterField.AddItem ("Calc Compl Date")
' Set default value
23 .cbFilterField.ListIndex = 0
24 End With
25 Call FixDTPickers
' ===== Exit Handler =====
Exit_WorkbookOpen:
26 Application.ScreenUpdating = True
27 Exit Sub
' ===== ERROR HANDLER =====
Error_In_WorkbookOpen:
28 With Err
29 sErrorDescription = "Error '" & .Number & " " & _
.Description & "' occurred in " & sProcSig & _
IIf(Erl <> 0, " at line " & CStr(Erl) & ".", ".")
30 End With
31 Select Case MsgBox(sErrorDescription, vbAbortRetryIgnore, "Error in " & sProcSig)
Case vbRetry
32 Resume
33 Case vbIgnore
34 Resume Next
35 Case Else
36 Resume Exit_WorkbookOpen
37 End
38 End Select
End Sub
Errors at line 12 > goes to Error Handler > fails at line 112 with:
Run-time error '32809'
Application-defined or object-defined error
Public Sub DataExtract()
...[more code]...
' Set 'last updated' statistics (dates)
4 Application.StatusBar = False
5 Application.ScreenUpdating = False
6 With ActiveWorkbook.Worksheets("Update")
' Obtain the start & end dates from the DTPickers
' this may cause errors... consider late binding of DTPickers
7 On Error Resume Next
8 dteStartDate = Format(.DTPickerStart, "yyyy-mm-dd")
9 dteEndDate = Format(.DTPickerEnd, "yyyy-mm-dd")
10 filterField = .cbFilterField.ListIndex
11 On Error GoTo Error_In_DataExtract
12 .Select
13 .Range("StartDate").Value = dteStartDate
14 .Range("EndDate").Value = dteEndDate
15 .Range("FilterField").Value = .cbFilterField.Value
16 .Range("FilterFieldIndex").Value = filterField
17 .Range("LastUpdated").Value = Date
18 .Range("UpdateStatus").Value = "Started"
19 End With
...[more code]...
' ===== ERROR HANDLER =====
Error_In_DataExtract:
'On Error Resume Next
110 Application.StatusBar = "Error occurred..."
111 With ActiveWorkbook.Worksheets("Update")
112 .Select
113 .Range("UpdateStatus").Value = "Failed"
114 End With
...[more code]...
Been testing with:
Excel 2007 with Vista / Win7
Excel 2010 with Vista
In Excel 2010: I deleted the 2 buttons from the "Update" worksheet & saved, closed, re-opened the spreadsheet to see if fixes problem. Problem still exists.
However... when I try to delete the combo box by selecting Design Mode > click combo box > Delete, it will crash excel. Will have to haven't tried removing the combo box using Excel 2007... anyhow just trying to pinpoint what object on the "Update" worksheet could be causing the errors/problems.
It would be so much easier if MS Office versions were multi-compatible... doh...
Any ideas please?