pedie
Well-known Member
- Joined
- Apr 28, 2010
- Messages
- 3,875
Hi 'm wanting to create a class which will be then used from the module to be referred to.
('m doing this because this code will be in add-in and will be using many workbooks. So will need to ensure that master workbook is hook to class workbook.)
I tried creating one class (xLtestCls) and tested as below
Please validate this code for me. I want to ensure that 'm doing the right thing.
Thanks in advance.
('m doing this because this code will be in add-in and will be using many workbooks. So will need to ensure that master workbook is hook to class workbook.)
I tried creating one class (xLtestCls) and tested as below
Please validate this code for me. I want to ensure that 'm doing the right thing.
Thanks in advance.
Code:
[/FONT][FONT=courier new]Option Explicit[/FONT]
[FONT=courier new]Private xlWb As Workbook[/FONT]
[FONT=courier new]Private xLWb_Name As String[/FONT]
[FONT=courier new]Property Let CurrentTemplate(varWb As Workbook)[/FONT]
[FONT=courier new] Set xlWb = varWb[/FONT]
[FONT=courier new]End Property[/FONT]
[FONT=courier new]Property Get CurrentTemplate() As Workbook[/FONT]
[FONT=courier new] Set CurrentTemplate = xlWb[/FONT]
[FONT=courier new]End Property
[/FONT][FONT=courier new]Sub test_1()[/FONT]
[FONT=courier new]Dim testCls As xLtestCls[/FONT]
[FONT=courier new]Windows("VBACLass.xlsm").Activate[/FONT]
[FONT=courier new]Set testCls = New xLtestCls[/FONT]
[FONT=courier new]testCls.CurrentTemplate = ActiveWorkbook[/FONT]
[FONT=courier new]
[/FONT]
[FONT=courier new] Windows("Class_.xlsm").Activate[/FONT]
[FONT=courier new] Call storeHistory(testCls.CurrentTemplate, ActiveWorkbook.Name & ". xTXT . " & testCls.WbCode)[/FONT]
[FONT=courier new] [/FONT]
[FONT=courier new] Windows("VBACLass.xlsm").Activate[/FONT]
[FONT=courier new] Call storeHistory(testCls.CurrentTemplate, ActiveWorkbook.Name & ". xTXT . " & testCls.WbCode)[/FONT]
[FONT=courier new] [/FONT]
[FONT=courier new] Windows("Class_.xlsm").Activate[/FONT]
[FONT=courier new] Call storeHistory(testCls.CurrentTemplate, ActiveWorkbook.Name & ". xTXT . " & testCls.WbCode)[/FONT]
[FONT=courier new]
[/FONT]
[FONT=courier new]testCls.CurrentTemplate.Activate[/FONT]
[FONT=courier new]testCls.CurrentTemplate = Nothing[/FONT]
[FONT=courier new]
[/FONT]
[FONT=courier new]End Sub[/FONT]
[FONT=courier new]
[/FONT]
[FONT=courier new]