Problem mit eigenem Add-In!
30.08.2003 08:00:15
Oliver S.
ich habe da ein Problem mit einem eigenen Add-In. Dieses Add-In soll die beinhalteten Code (basierend auf einen Code von hajo_Zi) in allen Exceldateien zur Verfügung stellen. Nachfolgend kommt mal der Inhalt des Add-In:
In Dieser Arbeitsmappe steht:
Option Explicit
Private Sub Workbook_Activate()
On Error GoTo neu
If Application.CommandBars("Symbolleiste xyz").Visible = False Then
Application.CommandBars("Symbolleiste xyz").Visible = True
End If
Exit Sub
neu:
Workbook_Open
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Zurück
End Sub
Private Sub Workbook_Open()
Dim cb As CommandBar
Dim CBC As CommandBarButton
Dim I%
On Error Resume Next
Set cb = Application.CommandBars.Add(Name:="Symbolleiste xyz", _
temporary:=True, Position:=msoBarTop)
On Error GoTo 0
If Application.CommandBars("Symbolleiste xyz").Visible = False Then
cb.Visible = True
For I = 1 To 2
Set CBC = cb.Controls.Add(Type:=msoControlButton)
With CBC
.Width = 50 ' Breite der Schalter
.Style = msoButtonCaption ' Text auf Schaltfläche
Select Case I
Case 1
.Caption = "Zeilenmarkierung An/Aus"
.OnAction = "Zeilenmarkierung_an_aus"
.TooltipText = "Taste drücken Zeilenmarkierung zu aktivieren oder zu deaktivieren"
Case 2
.Caption = "Ohne Funktion"
.OnAction = ""
.TooltipText = "Hier steht ein Text"
.BeginGroup = True
End Select
End With
Next I
End If
If ActiveCell.Column < 53 Then Auslesen
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
I = 0
On Error Resume Next
Application.CommandBars("Symbolleiste xyz").Delete
Zurück
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Zurück
If (ActiveCell.Row >= 1 And ActiveCell.Row <= 65000) Then
If ActiveCell.Column < 53 Then Auslesen
End If
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Zurück
I = 0
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Zurück
If (ActiveCell.Row >= 1 And ActiveCell.Row <= 65000) Then
If ActiveCell.Column < 53 Then Auslesen
End If
On Error GoTo neu
If Application.CommandBars("Symbolleiste xyz").Visible = False Then
Application.CommandBars("Symbolleiste xyz").Visible = True
End If
Exit Sub
neu:
Workbook_Open
End Sub
Sub Zurück()
If I = 0 Then
If StWert(1, 1, 1) <> "" Then
For InI = 1 To 52
If Worksheets(StWert(InI, 3, 3)).Range(StWert(InI, 2, 2)).Interior.ColorIndex = 35 Then
Worksheets(StWert(InI, 3, 3)).Range(StWert(InI, 2, 2)).Interior.ColorIndex = CInt(StWert(InI, 1, 1))
End If
Next InI
End If
End If
End Sub
Sub Auslesen()
If I = 0 Then
For InI = 1 To 52
StWert(InI, 1, 1) = Cells(ActiveCell.Row, InI).Interior.ColorIndex
StWert(InI, 2, 2) = Cells(ActiveCell.Row, InI).Address
StWert(InI, 3, 3) = ActiveSheet.Name
Cells(ActiveCell.Row, InI).Interior.ColorIndex = 35
Next InI
End If
End Sub
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Zurück
End Sub
In Modul1 steht:
Option Explicit
Public I As Integer
Public StWert(53, 3, 3) As String
Public InI As Integer
Sub Zeilenmarkierung_an_aus()
Zurück
If I = 0 Then
I = 1
ElseIf I = 1 Then
I = 0
End If
End Sub
Sub Zurück()
If I = 0 Then
If StWert(1, 1, 1) <> "" Then
For InI = 1 To 52
If Worksheets(StWert(InI, 3, 3)).Range(StWert(InI, 2, 2)).Interior.ColorIndex = 35 Then
Worksheets(StWert(InI, 3, 3)).Range(StWert(InI, 2, 2)).Interior.ColorIndex = CInt(StWert(InI, 1, 1))
End If
Next InI
End If
End If
End Sub
Nun erscheint beim Öffnen von Excel der Laufzeitfehler 91 und es wird die Zeile
StWert(InI, 3, 3) = ActiveSheet.Name
in der VBA-Umgebung markiert. Woran könnte das liegen? Geht das vielleicht nicht, was ich vorhabe?
Ich hoffe auf Antworten und bedanke mich schon mal im Voraus,
Oliver