I'm trying to open a Windows Form in VBS and having some difficulty :-(
This line works ok (I think):
Set frmPopup = CreateObject("System.Windows.Forms.Form")
But the following fails on the first line with: Microsoft VBScript runtime error: ActiveX component can't create object: 'System.Drawing.Size'
Set frmPopup.Size = CreateObject("System.Drawing.Size")
frmPopup.Size.Width = cmintPSPFormWidth
frmPopup.Size.Height = intPopupHeight
I guess that's because System.Drawing.Size needs the Height and Width parameters specified in the call?
The www talks about using:
Set frmPopup.Size = new System.Drawing.Size(1,2)
But this gives me: Variable is undefined: 'System'.
I've done a regasm on System.Windows.Forms.dll and System.Drawing.dll from my .NET 4 installation folder but it still doesn't work. Any ideas?
Size is a method, not a ProgID. You would probably need something like this:
Set frmPopup = CreateObject("System.Windows.Forms.Form")
Set frmDrwg = CreateObject("System.Drawing")
frmDrwg.Size 1, 2
But you must keep in mind that not all .NET object can be instantiated properly from VBS.