MPW
Well-known Member
- Joined
- Oct 7, 2009
- Messages
- 571
- Office Version
- 365
- Platform
- Windows
Hi All,
Using Office 2003 in XP
I can loop through controls but what is the syntax to add a control that I found while looping through a different userform?
Could someone please point out the error of my ways. Within reason of course.
Using Office 2003 in XP
I can loop through controls but what is the syntax to add a control that I found while looping through a different userform?
Code:
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim VBProj2 As VBIDE.VBProject
Dim VBComp2 As VBIDE.VBComponent
Dim CodeMod2 As VBIDE.CodeModule
Dim LineNum As Long
Set VBProj = oldwkbk.VBProject
For Each VBComp In VBProj.VBComponents
Set CodeMod = VBComp.CodeModule
Set VBProj2 = newwkbk.VBProject
Set VBComp2 = VBProj2.VBComponents.Add(VBComp.Type)
VBComp2.Name = VBComp.Name
For Each cCont In VBComp.Designer.Controls
VBComp2.Designer.Controls.Add(cCont.Type)
'I think the first part of this statement is right.
'However There is no "Type" allowed for the control property.
Next
Set VBProj2 = Nothing
Set VBComp2 = Nothing
Set CodeMod2 = Nothing
Next VBComp