I have programmed some Excel VBA and now I'm testing VBScript. I'm trying to create a form/window and after a while I managed to create this code:
Dim ExApp
ExApp = CreateObject("Excel.Application")
'ExApp.Application.Visible = True
Dim Workbook
Set Workbook = ExApp.Workbooks.Add
Dim myForm
Set myForm = Workbook.VBProject.VBComponents.Add(3)
Workbook.VBProject.VBComponents.Add(1).CodeModule.AddFromString "Function getForm()" & vbNewLine & "Set getForm = " & myForm.Name & vbNewLine & "End Function"
Dim userForm
Set userForm = ExApp.Run("getForm")
'VBA.UserForms.Add(myForm.Name).Show
It currently works but the method of creating a sub and calling/running it doesn't seem the best.
If I could call VBA.UserForms
/UserForms
then it would be better with the line VBA.UserForms.Add(myForm.Name).Show
(works in VBA) but I can't figure out how since VBA
is not an object in VBS or something like that.
I really can't find much information on this.