Directly referencing userforms externally

dnickelson

Board Regular
Joined
Oct 30, 2003
Messages
118
Getting stumped. Trying to play with WHScripting to access some of the excel features so I'm working with the objects in VBA first (so I at least have a starting space) but can't figure out how (or if it's possible) to access the Userforms in another workbook directly, keep getting errors. Various error messages possibly related to how I'm accessing the objects at all. I'm hoping to do various things with the userform (show\hide, grab variables, validation, etc), but stuck on the very first thing which is access it in the first place. Looked through the topics, but so much about userforms, can't filter it down to any external references. Rather not have to have the original workbook do all the work, but do I have a choice?

Code:
Sub something()
Dim wb As Workbook

Application.Workbooks.Open ("c:\copy of text.xls")
Workbooks("copy of text.xls").UserForms.Count


End Sub
         'Object doesn't support this property or method

Sub somethingelse()
Dim wb As Workbook

Application.Workbooks.Open ("c:\copy of text.xls")
With Workbooks("copy of text.xls")
    userform1.Show
End With

End Sub
        'object required

Sub somethingother()
Dim wb As Workbook

Application.Workbooks.Open ("c:\copy of text.xls")
With Workbooks("copy of text.xls")
    UserForms(1).Show
End With

End Sub
        'subscript out of range

haven't necessarily thought it all the way through, how to keep track of what's doing what, but the idea is that I can have a whscript file a user can open which will bring up userforms I've created in various workbooks, maybe word docs, etc. the main point is a point of reference external to any of the individual vba applications that can (hopefully) directly utilize some of the vba stuff I've already done.

maybe a little ambitious for not even being able to figure out this first part, but....
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Thanks much. I have done some of the 'hello world' type trials and the interface does work reasonably well. Thanks for the note about the UserForms not being populated when I might be expecting them to. I was activating and opening the work though so I thought that would have made them available, but I'll follow some other pathes until this makes sense to me.

The link was handy too. I'm actually trying it from WHScripts rather than .NET, but I'm actually looking to move over to VB rather than scripts anyway.
Like they say, the stuff Microsoft writes all works the same except where it doesn't. (or maybe that's just me that says that (y) )

Thanks,
-Dan
 
Upvote 0
I like to think of it as the great thing about Microsoft standards - is that theres so many to choose from :)
 
Upvote 0

Forum statistics

Threads
1,203,070
Messages
6,053,366
Members
444,658
Latest member
lhollingsworth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top