You must fully qualify enumeration constants in Visual Basic 2005. You might be accustomed to using a constant, such as xlUnderlineStyleSingle, when you assign an underline style to an Excel worksheet cell. In Visual Basic 2005, you must fully qualify the enumeration by typing Excel.XlUnderlineStyle.xlUnderlineStyleSingle, as shown in Listing 4.13. Note that Excel is an alias for the Microsoft.Office.Interop.Excel namespace.

Listing 4.13. Fully qualifying enumeration constants ' VBA

Dim myRange As Excel.Range myRange = Range("A1")

myRange.Font.Underline = xlUnderlineStyleSingle

' Visual Basic 2005

Dim myRange As Excel.Range

MyRange.Font.Underline = Excel.XlUnderlineStyle _ .xlUnderlineStyleSingle

0 0

Post a comment