I am looking at some code from my father’s VBA work. He isn’t a pro at it and neither am I. There is a problem and we can’t figure it out. To figure it out, I need to know about the ListView‘s View propoerty. The View property is assigned lvwReport and I am checking it on Google but there is no definition or I am not able to find it. I am surprised because there is no mention of it on any of Microsoft resources either.
Is there anyone/any resource that can tell me what this is exactly?
Here is the code and there is no any other variable called lvwReport as far as I can see:
Private Sub UserForm_Initialize()
ListView1.View = lvwReport
ListView1.Gridlines = True
ListView1.FullRowSelect = True
ListView1.ListItems.Clear
ListView1.ColumnHeaders.Clear
With ListView1.ColumnHeaders
.Add , , "MY COLUMN 1", 35
.Add , , "MY COLUMN 2", 30
.Add , , "MY COLUMN 3", 35
End With
For a = 2 To Cells(65000, 1).End(xlUp).Row
ListView1.ListItems.Add , , Cells(a, "A").Value
y = ListView1.ListItems.Count
ListView1.ListItems(y).ListSubItems.Add , , Cells(a, "B").Value
ListView1.ListItems(y).ListSubItems.Add , , Cells(a, "C").Value
ListView1.ListItems(y).ListSubItems.Add , , Cells(a, "D").Value
Next
End Sub
EDIT/NOTE: This is something from a lib called “Microsoft ListView Control 6.0 (SP6)”, I added it and problem resolved. However, I don’t understand what this is.
ListView is not native to VBA. Apparently you need to have VB6 installed. If from the VB Editor I select Tools, “Additional Controls” is greyed out. If you have VB6 installed, “Additional Controls” is available and will allow you to select Microsoft ListView.
A ListView has a number of alternative views: Icon, Small Icon, List and Report. If you play with Windows Explorer’s View options, you will see these alternatives. lvwReport selects the Report view.
Try googling “ListView VB” or “ListView VB6” for sites describing ListView.
Another option is to download Visual Basic 2010 Express. This is part of the Visual Studio/.NET development environment. The learning curve from VBA syntax to VB 2010 syntax is small. VB 2010 comes with thousands of extra features of which ListView is one. Because ListView is native to VB 2010 it is properly documented. VB 2010 is blindingly fast compared with VBA. The Express versions of the .NET sofware are all free. They may be single user but they are more than adequate for training and initial development. Only when you are ready need you pay to upgrade to a fuller version. The biggest downside, in my view, is there are so many features, it is difficult to find the one you want.