add-in bị lỗi Run time error '9'

Liên hệ QC

MinhCong

Thành viên gắn bó
Tham gia
28/5/09
Bài viết
1,645
Được thích
1,806
Nghề nghiệp
Xây dựng Cầu đường
Mình có chép file tableGPE.xla của Thầy Phạm Duy Long về chạy thì add-in báo lỗi:
Hiện hộp thoại Microsoft Visual Basic
Run-time error '9'
Subscript out of range
Mở xem trong đoạn code M_Menu có đoạn bị lỗi tô màu vàng cả 1 vùng (minh tô chữ đỏ). Nhờ các Bạn xem giúp Mình với. Mình dùng office 2003 (đã thử dùng cho nhiều máy khác) cũng như cài lại office vẫn bị lỗi.
....................
'Make sure the menus aren't duplicated
DeleteMenu
'Initialize the row counter
Row = 2
'Add the menus, menu items and submenu items using
'data stored on MenuSheet
'mymenu = Application.MenuBars(xlWorksheet).Menus.Count + 1
Do Until IsEmpty(MenuSheet.Cells(Row, 1))
With MenuSheet
MenuLevel = .Cells(Row, 1)
Caption = .Cells(Row, 2)
PositionOrMacro = .Cells(Row, 3)
Divider = .Cells(Row, 4)
FaceId = .Cells(Row, 5)
NextLevel = .Cells(Row + 1, 1)
End With
Select Case MenuLevel
Case 1 ' A Menu
'Add the top-level menu to the Worksheet CommandBar
PositionOrMacro = Application.MenuBars(xlWorksheet).Menus.Count + 2
Set MenuObject = Application.CommandBars(1). _
Controls.Add(Type:=msoControlPopup, _
Before:=PositionOrMacro, _
Temporary:=True)

MenuObject.Caption = Caption
Case 2 ' A Menu Item
If NextLevel = 3 Then
Set MenuItem = MenuObject.Controls.Add(Type:=msoControlPopup)
Else
Set MenuItem = MenuObject.Controls.Add(Type:=msoControlButton)
MenuItem.OnAction = PositionOrMacro
End If
MenuItem.Caption = Caption
If FaceId <> "" Then MenuItem.FaceId = FaceId
If Divider Then MenuItem.BeginGroup = True
Case 3 ' A SubMenu Item
Set SubMenuItem = MenuItem.Controls.Add(Type:=msoControlButton)
SubMenuItem.Caption = Caption
SubMenuItem.OnAction = PositionOrMacro
If FaceId <> "" Then SubMenuItem.FaceId = FaceId
If Divider Then SubMenuItem.BeginGroup = True
End Select
Row = Row + 1
Loop
End Sub
..............
 
Web KT
Back
Top Bottom