using john walkenbach's book "excel 2000 power programming with vba" i
ammended your code slightly & it works for me:
'===============================
Sub BuildMyForm()
Dim MyNewForm As Object
Set MyNewForm = _
ThisWorkbook.VBProject.VBComponents.Add(3)
With MyNewForm
.Properties("Height") = 246
.Properties("Width") = 616
.Name = "HelloWord"
.Properties("Caption") = "This is a test"
End With
VBA.UserForms.Add(MyNewForm.Name).Show
End Sub
'==================================

susan
On Oct 23, 8:57*am, "caveman.savant" <caveman.sav...@gmail.com> wrote:
> Thanks.
> Still having problem calling a new form.
> i found the following code but the AActiveDocument.VBProject part
> fails
>
> Sub BuildMyForm()
> * *Set mynewform = _
> * * * ActiveDocument.VBProject.VBComponents.Add(vbext_ct_MSForm)
> * * * With mynewform
> * * * * *.Properties("Height") = 246
> * * * * *.Properties("Width") = 616
> * * * * *.Name = "HelloWord"
> * * * * *.Properties("Caption") = "This is a test"
> * * * End With
> End Sub
>
> On Oct 22, 9:00*am, redeagle <redea...@discussions.microsoft.com>
> wrote:
>
>
>
> > Hi caveman.savant-
>
> > You should be able to do what you want. *The basic algorithm would beto
> > loop through your selection with a For/Each (For Each cell in Selection....)
> > to get the value of each cell. *Then you could declare and instanciate a
> > userform and the controls. *Once everything is defined you could display the
> > form.
>
> > Something like:
>
> > Sub Main()
>
> > Dim myCell as Variant
> > Dim myLabel as Label
>
> > 'Declare and instantiate new Userform and set properties
> > Dim uf As UserForm
> > Set uf = New UserForm
> > uf.Caption = "my dynamic form"
>
> > For Each myCell in Selection
> > * Set myLabel = New Label
> > * myLabel.Caption = myCell
> > * uf.Controls.Add myLabel
> > Next
>
> > 'Finally display your form
> > uf.Show
>
> > End Sub
>
> > ... my syntax may not be right, but that is the idea.
>
> > John
>
> > "caveman.savant" wrote:
> > > I'm not sure this can be done with VBA.
> > > I would like to create a macro that would allow me to select a group
> > > of cells from a worksheet and convert that selection into a userform.
>
> > > starting with
> > > * * ActiveCell.Offset(-3, -1).Range("A1:E4").Select
>
> > > The 1st row and 1st Column would be Labels, so I would loop thru and
> > > use the text to use for each caption.
>
> > > The rest of the cells would become a textbox for numerical data.
> > > Beside each textbox could be a spinner to select a value for the box.
>
> > > Once the form is created I'd like an option to save it. Otherwise I
> > > would use the dynamically created form to input data and return it the
> > > the originally selected cells
>
> > > Can Excel Macros create UserForms?
> > > Anyone with an idea how to start?- Hide quoted text -
>
> - Show quoted text -