Excel Properties() collection
Ok, not quite perfect. The object may not always be the same. In
other words, if I want to use ActiveWindow.FreezePanes, must first
select a range:
strmethod = "Select"
CallByName ExcelApp.Worksheets(strWorksheet).Range(strRange),
strmethod, VbMethod
strmethod = "FreezePanes"
CallByName ExcelApp.ActiveWindow, strmethod, VbLet, True
So, how do I pass it a different object on the fly without knowing the
full syntax of the property/method?
I know I could use something like this:
Select Case strObjToUse
Case "ExcelApp.ActiveWindow"
CallByName ExcelApp.ActiveWindow, strmethod, VbLet, True
Case "Range.Columns"
CallByName
ExcelApp.Worksheets(strWorksheet).Range(strRange). Columns, strmethod,
VbMethod
End Select
However, that still requires a LOT of programming in advance of
knowing which types are going to be used.
In MS Access, I can enumerate the properties collection of almost
anything. For instance:
Dim x As Long
For x = 1 To CurrentDb.Properties.Count
Debug.Print CurrentDb.Properties(x).Name
Next
In Excel, there is no way for me to enumerate all of properties of any
given object....So, I have to test each one or copy from the
documentation to determine, in advace, what I need to do. If I miss
anything, and the user wants to do it later, then it will still
require a recompile.
Troy
On Dec 14, 10:52 am, Jan Karel Pieterse
wrote:
Hi Troy,
ExcelApp.Worksheets("Sheet1").Range("B5:B12").Prop erties("WrapText") =
True
Instead, I have to do this for every property of the range collection:
ExcelApp.Worksheets("Sheet1").Range("B5:B12").Wrap Text = True
You should be able to use the CallByName method (function?) to achieve this.
Not sure about the entire syntax though.
Regards,
Jan Karel Pieterse
Excel MVPhttp://www.jkp-ads.com
Member of:
Professional Office Developer Associationwww.proofficedev.com
|