Using Excels Objects

The names that Excel gives to its objects when they are created often depend on the user's choice of Office UI Language. For example, when creating a blank workbook using Workbooks.Add, it will not always be called BookN, and the first worksheet in it will not always be called Sheetl. With the German UI, for example, they are called MappeN and Tabellel, respectively. Instead of referring to these objects by name, you should create an object reference as they are created, then use that object elsewhere in your code:

Dim Wkb As Workbook, Wks As Worksheet

Set Wbk = Workbooks.Add Set Wks = Wkb.Worksheets(1)

0 0

Post a comment