hoffe, hierbei kann mir jemand helfen!
Habe folgende Funktionen in einem Modul, die ich in einem Sheet aufrufe.
Prozedur im Modul:
Sub AddTextfeld(Position As Range)
Anzahl = 1
For Each Objekt In ActiveSheet.OLEObjects
If Objekt.progID = "Forms.TextBox.1" Then
Anzahl = Anzahl + 1
End If
Next
With ActiveSheet
Set Objekt = .OLEObjects.Add(ClassType:="Forms.TextBox.1", Left:=Position.Left, _
Width:=Position.Width, Top:=Position.Top, Height:=Position.Height)
Set TB = Objekt.Object
With TB
.Name = ActiveSheet.ComboBox1.Value & Anzahl
.BackColor = &HE0E0E0
.Font = "Georgia"
.Font.Bold = True
.Font.Size = 16
.TextAlign = fmTextAlignLeft
.EnterKeyBehavior = True
.TabKeyBehavior = True
.Height = 180
.Width = 340
.ScrollBars = fmScrollBarsVertical
.Locked = True
.AutoWordSelect = True
.DragBehavior = fmDragBehaviorDisabled
.WordWrap = True
.MultiLine = True
.SpecialEffect = fmSpecialEffectSunken
End With
End With
End Sub
Sub AddOptionButton(Position2 As Range)
Anzahl = 1
For Each Objekt In ActiveSheet.OLEObjects
If Objekt.progID = "Forms.OptionButton.1" Then
Anzahl = Anzahl + 1
End If
Next
With ActiveSheet
Set Objekt = .OLEObjects.Add(ClassType:="Forms.OptionButton.1", Left:=Position2.Left, _
Width:=Position2.Width, Top:=Position2.Top, Height:=Position2.Height)
Set OB = Objekt.Object
With OB
.Name = ActiveSheet.ComboBox1.Value & Anzahl
End With
End With
End Sub
Aufruf im Sheet:
Sub CommandButton5_Click()
If ComboBox1.Value "" Then
AddTextfeld Range("K20")
AddOptionButton Range("S25")
Else
MsgBox "Please choose ODM in Dropdown-Box!"
End If
End Sub
Sehr komisch... funktionier, aber sobald ich die Elemente per Button erstellt habe, funktioniert der Code nicht mehr =(
irgendetwas in der "Addtextfeld" Prozedur stimmt nicht!
Sobald ich das Textfeld habe sagt der Compiler mit "Object library invalid or contains references to object definitions that could not be found"
lg
adrian