Live-Forum - Die aktuellen Beiträge
Datum
Titel
24.04.2024 19:29:30
24.04.2024 18:49:56
24.04.2024 17:19:09
Anzeige
Archiv - Navigation
660to664
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
660to664
660to664
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Laufzeitfehler 402

Laufzeitfehler 402
03.09.2005 22:50:25
Thierry
Hallo!
Folgende Meldung erscheint wenn ich die Userform schliessen möchte:
Laufzeitfehler 402
Das oberste gebundene Formular muss zuerst geschlossen oder ausgeblendet werden.
Ich denke das Problem liegt darin, dass gleichzeitig zwei Userformen geöffnet sind. Die erste Userform hat nicht genügend Zeit sich zu schliessen bevor die neue Userform geöffnet wird.
Wie kann man dieses Problem lösen?
Thierry

9
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Laufzeitfehler 402
04.09.2005 00:48:09
Nepumuk
Hallo Thierry,
ohne den Code zu kennen kann ich nur raten. Soll ich?
Gruß
Nepumuk
Excel & VBA – Beispiele
AW: Laufzeitfehler 402
04.09.2005 15:49:20
Thierry
Hallo Nepumuk
Nein nein, du musst raten ;-)
Hier den Code für die erste Userform. Die Aufgabe dieser Userform ist es, die eingegebenen Daten in das Excelfile zu schreiben.
Option Explicit
'X in die Userform löeschen
Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function DrawMenuBar Lib "User32" (ByVal hWnd As Long) As Long
Private Const GWL_STYLE = -&H10
Private Const WS_SYSMENU = &H80000

Private Sub UserForm_Activate()
Dim lHwnd As Long, lStyle As Long
lHwnd = FindWindow("ThunderDFrame", Me.Caption)
If lHwnd <> 0 Then
lStyle = GetWindowLong(lHwnd, GWL_STYLE)
lStyle = SetWindowLong(lHwnd, GWL_STYLE, lStyle And Not WS_SYSMENU)
DrawMenuBar lHwnd
End If
End Sub


Private Sub optConclusione1_Change()
If optConclusione1.Value = False Then
optCasaUfficio.Enabled = True
optCorrispondenza.Enabled = True
optUfficioMobiliare.Enabled = True
Else
optCasaUfficio.Enabled = False
optCorrispondenza.Enabled = False
optUfficioMobiliare.Enabled = False
End If
End Sub


Private Sub optConclusione7_Change()
If optConclusione7.Value = False Then
optCasaUfficio.Enabled = True
optCorrispondenza.Enabled = True
optUfficioMobiliare.Enabled = True
Else
optCasaUfficio.Enabled = False
optCorrispondenza.Enabled = False
optUfficioMobiliare.Enabled = False
End If
End Sub


Private Sub cmdConfermareGenerali_Click()
On Error GoTo Fehler
Cells(ActiveCell.Row, 16) = IIf(optConclusione1, "a)Modifica non firmata", "") + IIf(optConclusione2, "b)Modifica firmata", "") + IIf(optConclusione3, "c)Modifica e nuovo affare", "") + IIf(optConclusione4, "d)Nuovo affare", "") + IIf(optConclusione5, "e)Rinnovo (scadenze)", "") + IIf(optConclusione6, "f)Rinnovo e nuovo affare", "") + IIf(optConclusione7, "g)Rinnovo d'ufficio", "")
Cells(ActiveCell.Row, 23) = IIf(optCasaUfficio, "Casa/ufficio ST", "") + IIf(optCorrispondenza, "Corrispondenza", "") + IIf(optUfficioMobiliare, "Ufficio Mobiliare", "")
Cells(ActiveCell.Row, 30) = txtVecchioPremioNetto.Value
Cells(ActiveCell.Row, 33) = txtNuovoPremioNetto.Value
Cells(ActiveCell.Row, 39) = IIf(optDisdettaSI, "si nuovo", "") + IIf(optDisdettaNo, "no", "") + IIf(optDisdettaGIA, "c'è già", "") + IIf(optDisdettaTolta, "tolta", "")
Cells(ActiveCell.Row, 42) = IIf(optSiConto, "si nuovo", "") + IIf(optNoConto, "no", "") + IIf(optGiaConto, "c'è già", "")
Cells(ActiveCell.Row, 46) = IIf(optGiovaniSi, "si", "") + IIf(optGiovaniNo, "no", "")
Cells(ActiveCell.Row, 48) = IIf(optConcorrenzaSi, "si", "") + IIf(optConcorrenzaNo, "no", "")
Cells(ActiveCell.Row, 45) = IIf(optCrossSellingSi, "si", "") + IIf(optCrossSellingNo, "no", "")
Unload Me
usfDatiGenerali.Hide
Fehler:
usfDatiGenerali.Hide
End Sub

Die zweite Userform wir durch folgenden Code
'Userform Cross Seeling oeffnen
If (Target.Column = 45 And Target.Row usfCrossSelling.Show
ElseIf (Target.Column = 45 And Target.Row usfCrossSellingNo.Show
End If
geöffnet.
'ganzer Code

Private Sub Worksheet_change(ByVal Target As Range)
On Error GoTo Fehler
Dim intRow As Integer
intRow = Target.Row
'Userform GMOMobiCasa oeffnen wenn MobiCasa
If (Target.Column = 10 And Target.Row <= 28 And Target.Value = "b)MobiCasa") Then
usfGMOMobiCasa.Show
'Userform GMOMobiPro oeffnen wenn MobiPro
ElseIf (Target.Column = 10 And Target.Row <= 28 And Target.Value = "d)MobiPro") Then
usfGMOMobiPro.Show
'Userform GMOProtekta oeffnen wenn Protekta
ElseIf (Target.Column = 10 And Target.Row <= 28 And Target.Value = "j)Protekta") Then
usfGMOProtekta.Show
'Userform usfDatiGenerali oeffnen wenn MobiCar
ElseIf (Target.Column = 10 And Target.Row <= 28 And Target.Value = "e)MobiCar") Then
usfDatiGenerali.Show
'Userform usfDatiGenerali oeffnen wenn MobiTour
ElseIf (Target.Column = 10 And Target.Row <= 28 And Target.Value = "f)MobiTour") Then
usfDatiGenerali.Show
'Userform usfDatiGenerali oeffnen wenn MobiSana
ElseIf (Target.Column = 10 And Target.Row <= 28 And Target.Value = "g)MobiSana") Then
usfDatiGenerali.Show
'Userform usfDatiGenerali oeffnen wenn MobiTech
ElseIf (Target.Column = 10 And Target.Row <= 28 And Target.Value = "h)MobiTech") Then
usfDatiGenerali.Show
'Userform usfDatiGenerali oeffnen wenn MobiLife
ElseIf (Target.Column = 10 And Target.Row <= 28 And Target.Value = "i)MobiLife") Then
usfDatiGenerali.Show
'Userform usfDatiGenerali oeffnen wenn Tariffa semplice
ElseIf (Target.Column = 10 And Target.Row <= 28 And Target.Value = "k)Tariffa semplice") Then
usfDatiGenerali.Show
'Userform usfDatiGenerali oeffnen wenn Malattia colletiva
ElseIf (Target.Column = 10 And Target.Row <= 28 And Target.Value = "l)Malattia colletiva") Then
usfDatiGenerali.Show
'Userform usfDatiGenerali oeffnen wenn Lainf/Compl. Lainf
ElseIf (Target.Column = 10 And Target.Row <= 28 And Target.Value = "m)Lainf/Compl. Lainf") Then
usfDatiGenerali.Show
'Userform usfDatiGenerali oeffnen wenn Trasporto
ElseIf (Target.Column = 10 And Target.Row <= 28 And Target.Value = "n)Trasporto") Then
usfDatiGenerali.Show
End If
'Wenn Cross Selling "no" dann Spalte 52 bis 93 verbinden
If (Target.Column = 45 And Target.Row <= 28 And Target.Value = "no") Then
Range(Cells(intRow, 52), Cells(intRow, 93)).MergeCells = True
End If
'Userform Cross Seeling oeffnen
If (Target.Column = 45 And Target.Row <= 28 And Target.Value = "si") Then
usfCrossSelling.Show
ElseIf (Target.Column = 45 And Target.Row <= 28 And Target.Value = "no") Then
usfCrossSellingNo.Show
End If
'Zelle AS 5 bis AS 28 nach aenderung sperren.
'Dim rngCell As Range
'Set Target = Intersect(Target, Range("AS5:AS28"))
'If Target Is Nothing Then Exit Sub
'Me.Unprotect ("twingo69")
'For Each rngCell In Target
'rngCell.Locked = rngCell <> ""
'Next
'Me.Protect ("twingo69")
'Speichern
If Target = Range("AI1") Then ActiveSheet.Name = Target
ActiveSheet.Name = "Settimana  " & Range("AI1").Value
ActiveSheet.Range("AI1").Calculate
Fehler:
End Sub

Die zweite Userform ist:

Private Sub cboConfermare1_Click()
'Daten speichern
On Error GoTo Fehler
Dim frm As UserForm
Set frm = usfCrossSelling
Range("AZ65536").End(xlUp).Offset(1, 0).Select
With frm
If (optSi1.Value = True) Then
ActiveCell.Offset(0, 0).Value = "SI"
Else
ActiveCell.Offset(0, 0).Value = "No"
End If
If (chkMobiTest.Value = True) Then
ActiveCell.Offset(0, 1).Value = "si"
Else
ActiveCell.Offset(0, 1).Value = ""
End If
If (chkOfferta.Value = True) Then
ActiveCell.Offset(0, 2).Value = "si"
Else
ActiveCell.Offset(0, 2).Value = ""
End If
If (chkMobilifeRischio = True) Then
ActiveCell.Offset(0, 3).Value = "si"
Else
ActiveCell.Offset(0, 3).Value = ""
End If
If (chkMobilifeMista = True) Then
ActiveCell.Offset(0, 4).Value = "si"
Else
ActiveCell.Offset(0, 4).Value = ""
End If
If (chkMobilifeFondiPuri = True) Then
ActiveCell.Offset(0, 5).Value = "si"
Else
ActiveCell.Offset(0, 5).Value = ""
End If
If (chkMobiLifeLegatoFondi = True) Then
ActiveCell.Offset(0, 6).Value = "si"
Else
ActiveCell.Offset(0, 6).Value = ""
End If
If (optAffareConcluso.Value = True) Then
ActiveCell.Offset(0, 7).Value = "affare concluso"
Else
If (optNonInteressato.Value = True) Then
ActiveCell.Offset(0, 7).Value = "non interessato"
Else
If (optGiàAssicurato.Value = True) Then
ActiveCell.Offset(0, 7).Value = "già assicurato"
Else
If (optNessunFabbisogno.Value = True) Then
ActiveCell.Offset(0, 7).Value = "nessun fabbisogno"
Else
If (optTrattativeInCorso.Value = True) Then
ActiveCell.Offset(0, 7).Value = "trattative in corso"
End If
End If
End If
End If
End If
ActiveCell.Offset(0, 7).Value = txtAltro
'Protekta
If (optSi2.Value = True) Then
ActiveCell.Offset(0, 13).Value = "SI"
Else
ActiveCell.Offset(0, 13).Value = "No"
End If
If (optAffareConcluso1.Value = True) Then
ActiveCell.Offset(0, 14).Value = "affare concluso"
Else
If (optNonInteressato1.Value = True) Then
ActiveCell.Offset(0, 14).Value = "non interessato"
Else
If (optGiàAssicurato1.Value = True) Then
ActiveCell.Offset(0, 14).Value = "già assicurato"
Else
If (optTrattativeInCorso1.Value = True) Then
ActiveCell.Offset(0, 14).Value = "trattative in corso"
Else
End If
End If
End If
End If
'MobiTour
If (optSi3.Value = True) Then
ActiveCell.Offset(0, 20).Value = "SI"
Else
ActiveCell.Offset(0, 20).Value = "No"
End If
If (optAffareConcluso2.Value = True) Then
ActiveCell.Offset(0, 21).Value = "affare concluso"
Else
If (optNonInteressato2.Value = True) Then
ActiveCell.Offset(0, 21).Value = "non interessato"
Else
If (optGiàAssicurato2.Value = True) Then
ActiveCell.Offset(0, 21).Value = "già assicurato"
Else
If (optTrattativeInCorso2.Value = True) Then
ActiveCell.Offset(0, 21).Value = "trattative in corso"
Else
End If
End If
End If
End If
'Sanitas
If (optSi4.Value = True) Then
ActiveCell.Offset(0, 27).Value = "SI"
Else
ActiveCell.Offset(0, 27).Value = "No"
End If
'Altro
If (optSi5.Value = True) Then
ActiveCell.Offset(0, 28).Value = "SI"
Else
ActiveCell.Offset(0, 28).Value = "No"
End If
ActiveCell.Offset(0, 29).Value = txtCheCosa.Value
'alle Feldern leeren
.optNo1.Value = True
.optNo2.Value = True
.optNo2.Value = True
.optNo3.Value = True
.optNo4.Value = True
.optNo5.Value = True
.chkMobiTest.Value = False
.chkOfferta.Value = False
.chkMobilifeRischio = False
.chkMobilifeMista = False
.chkMobilifeFondiPuri = False
.chkMobiLifeLegatoFondi = False
.optAffareConcluso.Value = False
.optNonInteressato.Value = False
.optGiàAssicurato.Value = False
.optNessunFabbisogno.Value = False
.optTrattativeInCorso.Value = False
.optAffareConcluso1.Value = False
.optNonInteressato1.Value = False
.optGiàAssicurato1.Value = False
.optTrattativeInCorso1.Value = False
.optAffareConcluso2.Value = False
.optNonInteressato2.Value = False
.optGiàAssicurato2.Value = False
.optTrattativeInCorso2.Value = False
.txtAltro = ""
.txtCheCosa = ""
End With
'usfCrossSelling schliessen
usfCrossSelling.Hide
Fehler:
usfCrossSelling.Hide
End Sub

Gruss.
Thierry
Anzeige
AW: Laufzeitfehler 402
04.09.2005 16:35:49
Nepumuk
Hallo Thierry,
du erwartest hoffentlich nicht, dass ich das nachbaue. Da taucht z.B. der Name "usfDatiGenerali" auf. Welche ist das? Reduziere den Code mal auf das Aufrufen und schließen der Userforms. Vor allen Dingen die Reihenfolge ist wichtig!!!
Gruß
Nepumuk
Excel & VBA – Beispiele
AW: Laufzeitfehler 402
04.09.2005 17:23:12
Thierry
Sorry Nepumuk
Wenn man VBA Anfänger ist, ist es immer schwierig zu wissen welche Informationen wichtig sind und welche nicht. Ich selber verstehe meistens nicht warum ich wann was im VBA mache.
Ich versuche den Code trotzdem zu verkürzen:
'Die Userform usfDatiGenerali wird geöffnet.

Private Sub cmdConfermareGenerali_Click()
On Error GoTo Fehler
Cells(ActiveCell.Row, 45) = IIf(optCrossSellingSi, "si", "") + IIf (optCrossSellingNo, "no", "")
Unload Me
'userform schliessen
usfDatiGenerali.Hide
Fehler:
usfDatiGenerali.Hide
End Sub

da jetzt die Daten in der Excel-Spalte 45 übertragen worden sind, öffnet sich durch folgenden Code die Userform "usfCrossSelling"

Private Sub Worksheet_change(ByVal Target As Range)
On Error GoTo Fehler
Dim intRow As Integer
intRow = Target.Row
'Userform Cross Seeling oeffnen
If (Target.Column = 45 And Target.Row <= 28 And Target.Value = "si") Then
usfCrossSelling.Show
ElseIf (Target.Column = 45 And Target.Row <= 28 And Target.Value = "no") Then
usfCrossSellingNo.Show
End If
Fehler:
End Sub

Die zweite Userform ist:

Private Sub cboConfermare1_Click()
'Daten speichern
On Error GoTo Fehler
Dim frm As UserForm
Set frm = usfCrossSelling
Range("AZ65536").End(xlUp).Offset(1, 0).Select
With frm
If (optSi1.Value = True) Then
ActiveCell.Offset(0, 0).Value = "SI"
Else
ActiveCell.Offset(0, 0).Value = "No"
End If
usw
End With
'usfCrossSelling schliessen
usfCrossSelling.Hide
Fehler:
usfCrossSelling.Hide
End Sub

' Das Problem ist, dass die zweite Userform zu schnell geöffnet wird wobei die erste Userform nicht die Zeit hat, sich zu schliessen.
Ich hoffe sehr, dass du mit diesen Angaben etwas Anfangen kannst
Freundliche Grüsse
Thierry
Anzeige
AW: Laufzeitfehler 402
04.09.2005 18:01:24
Nepumuk
Hallo Thierry,
ich kann den Fehler nicht nachvollziehen. kannst du die Mappe ohne Daten!! auf den Server laden?
Gruß
Nepumuk
Excel & VBA – Beispiele
AW: Laufzeitfehler 402
04.09.2005 19:58:22
Thierry
Hallo Nepumuk,
Leider ist Mappe nicht auf Deutsch. Hoffe aber, dass dies für dich kein Problem ist.
Du findest den Fehler so:
In der Spalte J5 wählst du z.B. "g)MobiSana" aus. Dadurch wird die Userform "Dati generali" geöffnet. In dieser Userfom wählst du unten links "Cross Selling" = Si, fatto. Danach bestätigst du diese Eingabe mit dem CommandButton.
Jetzt sollte sich die Userform "Cross Selling Si" öffnen. Wenn du jetzt irgend einen OptionButton auswählst und dann diese Eingabe mit dem CommandButton bestätigst erscheint die Fehlermeldung.
Gruss.
Thierry
https://www.herber.de/bbs/user/26289.xls
Anzeige
AW: Laufzeitfehler 402
04.09.2005 19:58:39
Thierry
Hallo Nepumuk,
Leider ist Mappe nicht auf Deutsch. Hoffe aber, dass dies für dich kein Problem ist.
Du findest den Fehler so:
In der Spalte J5 wählst du z.B. "g)MobiSana" aus. Dadurch wird die Userform "Dati generali" geöffnet. In dieser Userfom wählst du unten links "Cross Selling" = Si, fatto. Danach bestätigst du diese Eingabe mit dem CommandButton.
Jetzt sollte sich die Userform "Cross Selling Si" öffnen. Wenn du jetzt irgend einen OptionButton auswählst und dann diese Eingabe mit dem CommandButton bestätigst erscheint die Fehlermeldung.
Gruss.
Thierry
https://www.herber.de/bbs/user/26289.xls
Anzeige
AW: Laufzeitfehler 402
04.09.2005 21:53:58
Thierry
Hallo Nepumuk
Es fehlen mir die Worte! Danke, danke, danke!
Freundliche Grüsse und Gute Nacht! ;-)
Thierry

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige