Jonnyoforem
New Member
- Joined
- May 22, 2015
- Messages
- 32
VBA novice here so pardon my lack of understanding. I have a procedure, Sub addTraining () that when isolated works just fine and does what I want it to do. However when i run a separate procedure, Sub addEmployee (), the addTraining procedure starts giving me an error.
After running this section of code
I start getting errors in the addTraining procedure. Here's the relevant code for addTraining
The error occurs on the following line
And the error is: Run-time error '-2147467259 (80004005)': Method 'Properties' of object'_VBComponent' failed
Thanks in advance
Code:
Sub addEmployee ()
Dim k As String
Dim i As integer
'Find the userform that the user specifies
i = 1
Do While Cells(i, 3) <> ""
If Cells(i, 3).Value = ComboBox1.Value _
Then k = Cells(i, 5).Value
i = i + 1
Loop
'Display the specified UserForm
VBA.UserForms.Add(k).Show
End Sub
After running this section of code
Code:
VBA.UserForms.Add(k).Show
I start getting errors in the addTraining procedure. Here's the relevant code for addTraining
Code:
Sub addTraining
Dim MyUserForm As Variant
'cmb is a value taken from a combobox
'of a different userform
cmb = columnInsert.insertCombo.Value
Set MyUserForm = ThisWorkbook.VBProject.VBComponents (cmb & "Form")
hght = MyUserForm.Properties("Height")
hght = hght + 29
End Sub
The error occurs on the following line
Code:
hght = MyUserForm.Properties("Height")
And the error is: Run-time error '-2147467259 (80004005)': Method 'Properties' of object'_VBComponent' failed
Thanks in advance