Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
960to964
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
960to964
960to964
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Application.EnableEvents geht nicht

Application.EnableEvents geht nicht
13.03.2008 11:05:51
dirk
Hallo!
Habe folgendes kleines Macro geschrieben, um eine Klick-event zu verarbeiten.

Private Sub CheckBox20_Click()
lcell = ActiveSheet.OLEObjects("CheckBox20").LinkedCell
Range(lcell).Select
ActiveCell.Offset(0, -14).Select
If ActiveCell.Value = "Other reason (Please specify here)" Then
If Range(lcell).Value = "True" Then
OReason = InputBox("Please describe the other reason(s) for non compliance.", "Non- _
compliance reasons", "Other reason (Please specify here)")
If OReason = "" Then
Application.EnableEvents = False
Range(lcell).Value = "False"
Application.EnableEvents = True
End If
ActiveCell.Value = OReason
End If
Else
MsgBox ("The entry will be reset")
ActiveCell.Value = "Other reason (Please specify here)"
End If
MsgBox "Finished"
End Sub


Leider funktioniert das Abschalten der Application.EventsEnable nicht, d.h. sobald das Macro den Zellinhalt der Linkedcell (LCell) auf False setzt, started der Event das Macro nochmal.
Vieleicht weiss jemand wo der Fehler liegt oder ob der event fuer thissheet abgeschaltet werden kann.
Danke im Voraus
Dirk

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Application.EnableEvents geht nicht
13.03.2008 11:14:00
Renee
Hi Dirk,
Control-Objekte reagieren nicht auf Application.EventsEnable.
Probiers mal so:

Private Sub CheckBox20_Click()
If CheckBox20.Tag = "X" Then Exit Sub
lcell = ActiveSheet.OLEObjects("CheckBox20").LinkedCell
Range(lcell).Select
ActiveCell.Offset(0, -14).Select
If ActiveCell.Value = "Other reason (Please specify here)" Then
If Range(lcell).Value = "True" Then
OReason = InputBox("Please describe the other reason(s) for non compliance.", _
"Non-compliance reasons", "Other reason (Please specify here)")
If OReason = "" Then
CheckBox20.Tag = "X"
Range(lcell).Value = "False"
CheckBox20.Tag = ""
End If
ActiveCell.Value = OReason
End If
Else
MsgBox ("The entry will be reset")
ActiveCell.Value = "Other reason (Please specify here)"
End If
MsgBox "Finished"
End Sub


GreetZ Renée

Anzeige
AW: Application.EnableEvents geht nicht
13.03.2008 12:54:17
dirk
Hallo Renee,
geht leider nicht.
Checkbox20.tag bringt eine Fehlermeldung (Runtime error 438 'Object does not support this property or method".
checkBox20 ist vieleicht kein objekt? Ausserdemverstehe ich den Tag als zusaetzlichen speicherplatz und nicht als eventunterdruecker.
Gruss
Dirk

AW: Application.EnableEvents geht nicht
13.03.2008 13:04:46
Renee
Hi Dirk,
Ich hab es halt nicht getestet, dann so:

Option Explicit
Public bActive As Boolean
Private Sub CheckBox20_Click()
If bActive Then Exit Sub
lcell = ActiveSheet.OLEObjects("CheckBox20").LinkedCell
Range(lcell).Select
ActiveCell.Offset(0, -14).Select
If ActiveCell.Value = "Other reason (Please specify here)" Then
If Range(lcell).Value = "True" Then
OReason = InputBox("Please describe the other reason(s) for non compliance.", _
"Non-compliance reasons", "Other reason (Please specify here)")
If OReason = "" Then
bActive = True
Range(lcell).Value = "False"
bActive = False
End If
ActiveCell.Value = OReason
End If
Else
MsgBox ("The entry will be reset")
ActiveCell.Value = "Other reason (Please specify here)"
End If
MsgBox "Finished"
End Sub


GreetZ Renée

Anzeige
AW: Application.EnableEvents geht nicht
13.03.2008 13:31:25
dirk
Hallo Renee,
immer noch kein Erfolg.
Sobald die Zelle geaendert wird (Range(lcell).Value = "False") triggert das einen neuen checkbutton30_Click event.
Ich versuche ja, den status des buttons zu aendern und diesen Event zu unterdruecken.
Deswegen der application.EnableEvent = False Aufruf.
Sonst noch eine Idee?
Dirk

AW: Application.EnableEvents geht nicht
13.03.2008 13:40:00
Renee
Hi Dirk,
Na sehr schön, von einer Checkbox30 war bis jetzt nie die Rede.
Setzte in derem Click_event als erste Zeile:

If bActive Then Exit Sub


GreetZ Renée

Anzeige
AW: Application.EnableEvents geht nicht
13.03.2008 14:15:00
dirk
Renee,
Now I got it!
Du faengst den zweiten click event ab. Habe die Zeile so geandert:
If bActive = True Then Exit Sub
und bActive in the global Vars aufgenommen.
Funzt jetzt einwandfrei!
Vielen Dank nochmal!
Dirk
Hier nochmal das komplette Macro:

Private Sub CheckBox20_Click()
If bActive = True Then Exit Sub
lcell = ActiveSheet.OLEObjects("CheckBox20").LinkedCell
Range(lcell).Select
ActiveCell.Offset(0, -14).Select
If ActiveCell.Value = "Other reason (Please specify here)" Then
If Range(lcell).Value = "True" Then
OReason = InputBox("Please describe the other reason(s) for non compliance.", "Non- _
compliance reasons", "Other reason (Please specify here)")
If OReason = "" Then
bActive = True
Range(lcell).Value = "False"
OReason = "Please describe the other reason(s) for non compliance."
bActive = False
End If
ActiveCell.Value = OReason
End If
Else
MsgBox ("The entry will be reset")
ActiveCell.Value = "Other reason (Please specify here)"
End If
End Sub


Anzeige

46 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige