View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Troy[_9_] Troy[_9_] is offline
external usenet poster
 
Posts: 9
Default Excel Properties() collection

I've developed a solution that Exports Crystal reports to Excel, then
formats Excel with a few additional things after the export that
Crystal has a hard time doing (e.g. FreezePanes, WrapText, etc).

All is well, except that any additional tweaks that the end user wants
to the Excel file requires a recompile of my code every time. The
reason - No collection in Excel is accessible with a .Properties()
collection. For instance, I cannot do this for a range collection:

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

The alternative is ugly - Create a wrapper class for each Excel class
that I want to use, and give it accessible properties for every
property in advance. That's a huge set of wrappers that I want to
avoid, and I want to avoid a recompile for a simple addition like
"Range(strRange).Columns.AutoFit". I'd much rather be able to write
something similar to
"Range(strRange").Properties("Columns").Properties ("AutoFit") = True

So, my question is this: Is there a way to do this, from an external
program automating Excel through COM, that I cannot seem to find?