Excel + Visual Basic does not look like a happy marriage, unless you are aware of all the pitfalls... Now this:
I cannot seem to use the UsedRange property no matter how I declare it, as Range, as Property, as Variant, nothing works! All I get is a Type mismatch all the time. Could someone please help!
Below follows the code:
Sub LowerTaxaAdd(ByVal Node As MSComctlLib.Node)
'Maketree declarations
Dim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer, t As Integer
Dim nNode As Node, RNode As Node
'Excel declarations
Dim xlapp As Excel.Application
Dim xlbook As Workbook
Dim xlsheet As Worksheet
Dim myRange As Range
'taxon declarations
Dim phylum As String
Dim xlTaxon(1 To 16, 1 To 1900) As String
Dim taxcat(1 To 16) As String
Dim taxparent As String, taxkey As String, parentstack As String
'set up Excel file
Set xlapp = New Excel.Application
Set xlbook = xlapp.Workbooks.Open("F:\Hierarchy\FaEu_Animalia3.2.xls"
xlapp.Visible = False
'set up Treeview
TWC.ImageList = Nothing
TWC.Visible = True
cmdRefresh.Left = 1080
cmdRefresh.Width = 4095
lblLVinfo.Visible = False
shpLVinfo.Visible = False
LV.Visible = False
LVTaxStat.Visible = False
lblTaxStat.Caption = ""
'*Add other taxa
l = 4
i = Mid(Node.Key, 3, Len(Node.Key) - 2)
taxparent = Node.Key
'determine taxon level
Set xlsheet = xlbook.Worksheets(i)
Set myRange = xlsheet.UsedRange
Debug.Print "range xl sheet: " & myRange
[...snip...]
End Sub
I cannot seem to use the UsedRange property no matter how I declare it, as Range, as Property, as Variant, nothing works! All I get is a Type mismatch all the time. Could someone please help!
Below follows the code:
Sub LowerTaxaAdd(ByVal Node As MSComctlLib.Node)
'Maketree declarations
Dim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer, t As Integer
Dim nNode As Node, RNode As Node
'Excel declarations
Dim xlapp As Excel.Application
Dim xlbook As Workbook
Dim xlsheet As Worksheet
Dim myRange As Range
'taxon declarations
Dim phylum As String
Dim xlTaxon(1 To 16, 1 To 1900) As String
Dim taxcat(1 To 16) As String
Dim taxparent As String, taxkey As String, parentstack As String
'set up Excel file
Set xlapp = New Excel.Application
Set xlbook = xlapp.Workbooks.Open("F:\Hierarchy\FaEu_Animalia3.2.xls"
xlapp.Visible = False
'set up Treeview
TWC.ImageList = Nothing
TWC.Visible = True
cmdRefresh.Left = 1080
cmdRefresh.Width = 4095
lblLVinfo.Visible = False
shpLVinfo.Visible = False
LV.Visible = False
LVTaxStat.Visible = False
lblTaxStat.Caption = ""
'*Add other taxa
l = 4
i = Mid(Node.Key, 3, Len(Node.Key) - 2)
taxparent = Node.Key
'determine taxon level
Set xlsheet = xlbook.Worksheets(i)
Set myRange = xlsheet.UsedRange
Debug.Print "range xl sheet: " & myRange
[...snip...]
End Sub