Wednesday, June 20, 2018

excel - Conflict between Dim x As Control and a predifined Control module




I am adding to a rather large workbook, with many sheets and macros, unfortunately they are not my domain to change... these include a module called Control, a sheet in the spreadsheet called Control and another sub in a different module using "Dim Control As Object" and then "Set Control = Worksheets(CONTROL_SHEET)"



My problem is I need to use "Dim chb As Control" but when my module is called I get the error:




Compile error: A module is not a valid type




Is there a way to define which Control I'm using in the Dim statement e.g. "Dim chb As Vartype.Control" ?



Answer



I think you should be able to specify it using MSForms as the root:



Public Sub test()
Dim x As MSForms.Control
End Sub

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...