Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
812to816
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
812to816
812to816
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

textbox löst kein automatiesierungsereignis aus

textbox löst kein automatiesierungsereignis aus
18.10.2006 21:01:12
Julia
hallo,
also ich hab ne uf wo listbox und textfelder automatisch per knopf druck hinzugefügt werden sollen:
Private newButton As Control
Private WithEvents myComboBox As ComboBox
Private WithEvents myBox As TextBox

Private Sub CommandButton1_Click()
ComboBox1.Clear
UserForm1.Hide
End Sub


Private Sub CommandButton2_Click()
If UserForm1.TextBox1.Value = True And UserForm1.TextBox2.Value = True Then
tmp = MsgBox("Noch ein Spare Part in den Reperaturplan mit einfügen ?", vbYesNo, "")
End If
If tmp = 6 Then
Set newComboBox = Controls.Add("Forms.ComboBox.1")    'fügt neuen Button ein
newComboBox.Left = 24
newComboBox.Top = 90
newComboBox.Width = 24
newComboBox.Height = 24
Set myComboBox = newComboBox
Set newBox = Controls.Add("Forms.Box.1")    'fügt neuen Button ein
newBox.Left = 24
newBox.Top = 90
newBox.Width = 24
newBox.Height = 24
Set myBox = newBox
End If
End Sub

aber mit textboxen scheint es ja wie oben angegeben nicht zu gehen, da vba dann immer sagt:
"das objekt löst keine automatisierungsereignisse aus"
Ein Objekt muß eine Standard-Quellschnittstelle zur Verfügung stellen, so daß Sie für die zugehörigen Ereignisse Ereignisprozeduren schreiben können. Dieser Fehler hat folgende Ursachen und Lösungen:
Sie haben versucht, eine Ereignisprozedur für ein Ereignis eines Objekt zu schreiben, aber dieses Ereignis ist außerhalb des Objekts nicht verfügbar.
das sagt vba dazu...aber wie kann ich es anders machen!?
habt ihr eine idee!?

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: textbox löst kein automatiesierungsereignis aus
18.10.2006 23:50:21
Nepumuk
Hallo Julia,
welches Ereignis willst du denn nutzen? Eine Klasse stellt nicht alle Ereignisse zur Verfügung.
Gruß
Nepumuk
AW: textbox löst kein automatiesierungsereignis aus
19.10.2006 09:07:21
Rudi
Hallo,
lege dir eine UF mit 2 CommandButtons (cmdMehr und cmdFertig) an, kopiere den code hinein und starte die UF.
Option Explicit
Const h = 18    'Höhe der Controls
Const wLstBx = 80   'Breite Listbox
Const wTxt1 = 80    'Breite Textfeld1
Const wTxt2 = 120   'Breite Textfeld2
Const lLstBx = 10   'linke Pos. Listbox
Dim objLstBx As Control, objTxt1 As Control, objTxt2 As Control
Private Sub cmdFertig_Click()
Dim i As Integer
Dim vntdaten
ReDim vntdaten(1 To (Me.Controls.Count - 2) / 3, 1 To 3)
For i = 3 To Me.Controls.Count Step 3
vntdaten(i / 3, 1) = Me.Controls(i - 1).Value
vntdaten(i / 3, 2) = Me.Controls(i).Value
vntdaten(i / 3, 3) = Me.Controls(i + 1).Value
Next
With Sheets(2)
.Range(.Cells(1, 1), .Cells(UBound(vntdaten, 1), 3)) = vntdaten
End With
Me.Hide
Unload Me
End Sub
Private Sub cmdMehr_Click()
Dim vntLstBx, objTmpLstBx As Control, objTmtTxt1 As Control, objTmtTxt2 As Control
Dim lTxt1
Dim lTxt2
Set objTmpLstBx = objLstBx
Set objTmtTxt1 = objTxt1
Set objTmtTxt2 = objTxt2
vntLstBx = Array("a", "b", "c", "d", "e", "f", "g", "h")
Set objLstBx = Me.Controls.Add("forms.listbox.1")
With objLstBx
.Left = objTmpLstBx.Left
.Top = 10 + h + objTmpLstBx.Top
.Height = h + 3
.Width = wLstBx
.List = vntLstBx
End With
Set objTxt1 = Me.Controls.Add("forms.textbox.1")
With objTxt1
.Left = objTmtTxt1.Left
.Top = 10 + h + objTmtTxt1.Top
.Height = h
.Width = wTxt1
End With
Set objTxt2 = Me.Controls.Add("forms.textbox.1")
With objTxt2
.Left = objTmtTxt2.Left
.Top = 10 + h + objTmtTxt2.Top
.Height = h
.Width = wTxt2
End With
cmdMehr.Top = objLstBx.Top + h + 10
cmdFertig.Top = cmdMehr.Top
Me.Height = cmdMehr.Top + cmdMehr.Height + 50
Me.Width = 30 + wLstBx + wTxt1 + wTxt2 + 20
End Sub
Private Sub UserForm_Initialize()
Dim vntLstBx
Dim lTxt1
Dim lTxt2
vntLstBx = Array("a", "b", "c", "d", "e", "f", "g", "h")
lTxt1 = 10 + wLstBx + 10    'linke Pos. Textbox1
lTxt2 = lTxt1 + wTxt1 + 10  'linke Pos. Textbox2
Set objLstBx = Me.Controls.Add("forms.listbox.1")
With objLstBx
.Left = lLstBx
.Top = 10
.Height = h + 3
.Width = wLstBx
.List = vntLstBx
End With
Set objTxt1 = Me.Controls.Add("forms.textbox.1")
With objTxt1
.Left = lTxt1
.Top = 10
.Height = h
.Width = wTxt1
End With
Set objTxt2 = Me.Controls.Add("forms.textbox.1")
With objTxt2
.Left = lTxt2
.Top = 10
.Height = h
.Width = wTxt2
End With
cmdMehr.Top = objLstBx.Top + h + 10
cmdFertig.Top = cmdMehr.Top
Me.Height = cmdMehr.Top + cmdMehr.Height + 50
Me.Width = 30 + wLstBx + wTxt1 + wTxt2 + 20
End Sub

Gruß
Rudi
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige