I need to display information read from a database in a table in a VBA userform (MS Excel). I am aware of MSFlexGrid, and have tried to use it, but I have ran into a brickwall due to its well documented limitations. The following are the features I need from the table/grid control:
-row-based event detection (mouseover, mouse clicks, etc)
-ability to choose between, on a per-column basis:
Automatic resizing of column-widths if text in a row is too long
OR
Text wrapping if string in a row is too long for a defined column-width
-Column sort
-Automatic vertical scrollbar if number of rows is large
-Ability to have hidden columns
-Freeware!
Are there any controls that exist out there that have all of these abilities? Do you have any other solutions for displaying data in a grid in a VBA userform? Thanks for your help.
Be careful with the Spreadsheet control, it doesn't support ALL excel's objects, methods, collections, and properties.
For example, today I was helping someone with this object. They wanted to use AutoFilter and automatically filter a specific item, but the Spreadsheet control doesn't support "Criteria1, Field, Criteria2, etc" for Autofilter. I did manage to find a workaround, after some digging.
It appears to be the case but I really think it may be that the control uses a slightly different "Range" object with the same or similar props, methods, and functions etc. So the types may not be 100% equilivalent and cause the early binding type mismatch error.
I just use early binding to get my code in place and take advantage of the intellisense and then switch it to late binding and Im good to go.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
It appears to be the case but I really think it may be that the control uses a slightly different "Range" object with the same or similar props, methods, and functions etc. So the types may not be 100% equilivalent and cause the early binding type mismatch error..
I see...do you think it has anything to do with the fact that it's the Web Components object model and not Excel?
Originally Posted by RobDog888
I just use early binding to get my code in place and take advantage of the intellisense and then switch it to late binding and Im good to go.
Even if your code's written in VBA? (I can understand automating, say, access from excel...but I meant automating excel from within excel).
If you find any of my posts of good help, please rate it
Yes, I meant Excel VBA inside of Excel VBA for just the code concerning the UserForm with the web control on it.
....for the web components you still get the intellisense even without the reference. The intellisense treats it (Spreadsheet object) as if it's a worksheet object...
If you find any of my posts of good help, please rate it
Yes, but if you declare an object variable of Range and then try to set the range to a range on the web control you get the type mismatch erro like we been over. SoI was meaning that when writting the code that is directly related to the web control I do this but never removing any references as thats not needed.
VB Code:
Dim oRange As [b]Excel.Range[/b]
Set oRange = Spreadsheet1.Range(Spreadsheet1.Cells(1, 1), Spreadsheet1.Cells(1, 2))
MsgBox oRange.Address '"$A$1:$B$1"
VB Code:
Dim oRange As Object
Set oRange = Spreadsheet1.Range(Spreadsheet1.Cells(1, 1), Spreadsheet1.Cells(1, 2))
MsgBox oRange.[b]Address[/b] '"$A$1:$B$1"
Where .Address is not displayed when using late binding to get around the type error. So I use this first and then switch it over.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.