Rubberduck icon indicating copy to clipboard operation
Rubberduck copied to clipboard

Inspection for Use of New keyword for non-creatable class

Open ThunderFrame opened this issue 8 years ago • 1 comments

Some CoClasses don't have public constructors, so VBA can't New 'em up.

Set myWorkbook = New Workbook

With New Workbook
  Beep
End With

The quickfix would require knowing the factory method(s) and be host/TLB specific.

Set myWorkbook = Workbooks.Add

With Workbooks.Add
  Beep
End With

ThunderFrame avatar Nov 28 '16 11:11 ThunderFrame