Перешёл на 2007 офис и получил следующую проблему:
при запуске макроса
Public dt As Date, n1 As String, n2 As String
Sub ComboBox_AfterUpdate()
dt = ActiveSheet.Range("b" & ActiveSheet.[b16] + 16)
UserForm1.Show
'Call InsetrRows
End Sub
Sub InsetrRows()
Dim appExcel As Excel.Application
Dim shtExcel As Excel.Worksheet
Dim Rows As Long
Dim MyArray() As Variant
Dim i As Long, r As Long
Dim Counter As Integer
Dim CounterAll As Integer
Counter = 1
CounterAll = 1
n1 = "Âèá³ð äàííèõ ïî ë³í³¿ "
Rows = 2500
i = 1
'Set appExcel = CreateObject("Excel.Application.8")
Set appExcel = CreateObject("Excel.Application.11")
' Âûáîð äëÿ ëèíèè 320--------------------------------------------------
appExcel.Workbooks.Open ThisWorkbook.Path & "\Line320.xls", UpdateLinks:=0
Set shtExcel = appExcel.Worksheets("Data")
n2 = "'Nagema 320'"
Counter = 1
i = 1
ReDim MyArray(1 To 9, 1 To 11)
' UserForm1.Show
For r = 8 To Rows
If shtExcel.Cells(r, 1) = dt Then
MyArray(i, 1) = shtExcel.Cells(r, 2)
MyArray(i, 2) = shtExcel.Cells(r, 11)
MyArray(i, 3) = shtExcel.Cells(r, 9)
MyArray(i, 4) = shtExcel.Cells(r, 12)
MyArray(i, 5) = shtExcel.Cells(r, 13)
MyArray(i, 6) = shtExcel.Cells(r, 15)
MyArray(i, 7) = shtExcel.Cells(r, 16)
MyArray(i, 8) = shtExcel.Cells(r, 29)
MyArray(i, 9) = shtExcel.Cells(r, 30)
MyArray(i, 10) = shtExcel.Cells(r, 48)
MyArray(i, 11) = shtExcel.Cells(r, 49)
i = i + 1
End If
Counter = Counter + 1
CounterAll = CounterAll + 1
PctDone = Counter / (Rows - 8)
PctDoneAll = CounterAll / (10000)
Call UpdateProgress(PctDone, PctDoneAll)
Next r
appExcel.Workbooks("Line320.xls").Close SaveChanges:=False
Set appExcel = Nothing
Range(Cells(6, 8), Cells(14, 18)) = MyArray
' Êîíåö äëÿ ëèíèè 320 --------------------------------------------------
' Âûáîð äëÿ ëèíèè 850--------------------------------------------------
Set appExcel = CreateObject("Excel.Application.11")
appExcel.Workbooks.Open ThisWorkbook.Path & "\Line850.xls", UpdateLinks:=0
Set shtExcel = appExcel.Worksheets("Data")
n2 = "'Nagema 850'"
Counter = 1
i = 1
ReDim MyArray(1 To 9, 1 To 11)
For r = 8 To Rows
If shtExcel.Cells(r, 1) = dt Then
MyArray(i, 1) = shtExcel.Cells(r, 2)
MyArray(i, 2) = shtExcel.Cells(r, 11)
MyArray(i, 3) = shtExcel.Cells(r, 9)
MyArray(i, 4) = shtExcel.Cells(r, 12)
MyArray(i, 5) = shtExcel.Cells(r, 13)
MyArray(i, 6) = shtExcel.Cells(r, 15)
MyArray(i, 7) = shtExcel.Cells(r, 16)
MyArray(i, 8) = shtExcel.Cells(r, 29)
MyArray(i, 9) = shtExcel.Cells(r, 30)
MyArray(i, 10) = shtExcel.Cells(r, 48)
MyArray(i, 11) = shtExcel.Cells(r, 49)
i = i + 1
End If
Counter = Counter + 1
CounterAll = CounterAll + 1
PctDone = Counter / (Rows - 8)
PctDoneAll = CounterAll / (10000)
Call UpdateProgress(PctDone, PctDoneAll)
Next r
appExcel.Workbooks("Line850.xls").Close SaveChanges:=False
Set appExcel = Nothing
Range(Cells(15, 8), Cells(23, 18)) = MyArray
' Êîíåö äëÿ ëèíèè 850 --------------------------------------------------
' Âûáîð äëÿ ëèíèè 315--------------------------------------------------
Set appExcel = CreateObject("Excel.Application.11")
appExcel.Workbooks.Open ThisWorkbook.Path & "\Line315.xls", UpdateLinks:=0
Set shtExcel = appExcel.Worksheets("Data")
n2 = "'Nagema 315'"
Counter = 1
i = 1
ReDim MyArray(1 To 9, 1 To 11)
For r = 8 To Rows
If shtExcel.Cells(r, 1) = dt Then
MyArray(i, 1) = shtExcel.Cells(r, 2)
MyArray(i, 2) = shtExcel.Cells(r, 11)
MyArray(i, 3) = shtExcel.Cells(r, 9)
MyArray(i, 4) = shtExcel.Cells(r, 12)
MyArray(i, 5) = shtExcel.Cells(r, 13)
MyArray(i, 6) = shtExcel.Cells(r, 15)
MyArray(i, 7) = shtExcel.Cells(r, 16)
MyArray(i, 8) = shtExcel.Cells(r, 29)
MyArray(i, 9) = shtExcel.Cells(r, 30)
MyArray(i, 10) = shtExcel.Cells(r, 48)
MyArray(i, 11) = shtExcel.Cells(r, 49)
i = i + 1
End If
Counter = Counter + 1
CounterAll = CounterAll + 1
PctDone = Counter / (Rows - 8)
PctDoneAll = CounterAll / (10000)
Call UpdateProgress(PctDone, PctDoneAll)
Next r
appExcel.Workbooks("Line315.xls").Close SaveChanges:=False
Set appExcel = Nothing
Range(Cells(24, 8), Cells(32, 18)) = MyArray
' Êîíåö äëÿ ëèíèè 315 --------------------------------------------------
' Âûáîð äëÿ ëèíèè 317 --------------------------------------------------
Set appExcel = CreateObject("Excel.Application.11")
appExcel.Workbooks.Open ThisWorkbook.Path & "\Line317.xls", UpdateLinks:=0
Set shtExcel = appExcel.Worksheets("Data")
n2 = "'Nagema 317'"
Counter = 1
i = 1
ReDim MyArray(1 To 9, 1 To 11)
For r = 8 To Rows
If shtExcel.Cells(r, 1) = dt Then
MyArray(i, 1) = shtExcel.Cells(r, 2)
MyArray(i, 2) = shtExcel.Cells(r, 11)
MyArray(i, 3) = shtExcel.Cells(r, 9)
MyArray(i, 4) = shtExcel.Cells(r, 12)
MyArray(i, 5) = shtExcel.Cells(r, 13)
MyArray(i, 6) = shtExcel.Cells(r, 15)
MyArray(i, 7) = shtExcel.Cells(r, 16)
MyArray(i, 8) = shtExcel.Cells(r, 29)
MyArray(i, 9) = shtExcel.Cells(r, 30)
MyArray(i, 10) = shtExcel.Cells(r, 48)
MyArray(i, 11) = shtExcel.Cells(r, 49)
i = i + 1
End If
Counter = Counter + 1
CounterAll = CounterAll + 1
PctDone = Counter / (Rows - 8)
PctDoneAll = CounterAll / (10000)
Call UpdateProgress(PctDone, PctDoneAll)
Next r
appExcel.Workbooks("Line317.xls").Close SaveChanges:=False
Set appExcel = Nothing
Range(Cells(33, 8), Cells(41, 18)) = MyArray
' Êîíåö äëÿ ëèíèè 317 --------------------------------------------------
Unload UserForm1
Windows("Short report1.xls").Activate
End Sub
Sub UpdateProgress(Pct, PctAll)
With UserForm1
.Label1.Caption = n1 + n2
.FrameProgress.Caption = Format(Pct, "0%")
.FrameAllProgress.Caption = Format(PctAll, "0%")
.LabelProgress.Width = Pct * (.FrameProgress.Width - 10)
.LabelAllProgress.Width = PctAll * (.FrameProgress.Width - 10)
.Repaint
End With
End Sub
Выдает ошибку "Activex component cant creat object" на строку:
Set appExcel = CreateObject("Excel.Application.11")
Хотелось-бы знать что поменялось и как даная проблема решается
Спасибо