R
rharlamert
I have developed an automation routine in C# (.NET 2.0) to populate
data and run Macros in an Excel spreadsheet. This works absolutely
flawlessly in conjunction with Excel XP (2002) or Excel 2003 using the
Office XP PIAs. Excel remains completely hidden from the user (the
way I want it) and I clean-up the COM objects and the Excel instance
when the routine completes. Nice and clean. The user has no idea
(visually) that Excel was ever opened.
Now management tells me they want to support Excel 2000 as well. Ok,
so I remove my references to the Office XP PIAs and replace it with a
reference to the Excel 9.0 TypeLib. Interops generate in VS and I'm
up and running.
Data population (writing values to ranges) works fine as it did
before. But when I call the necessary Macros in the Excel workbook
from C#, Excel seems to just hang... or execute very slowly. Taking
minutes to accomplish what previously took a fraction of a second.
Please remember, I'm not showing the Excel window to the user, it is
hidden.
Most, if not all, the KB docs on MSDN reference these procedures using
Excel XP (2002), Excel 2003, or Excel 2007, which is understandable
since these are the only versions for which PIAs are provided.
Needless to say, I cannot find anything specific to Excel 2000 on MSDN
regarding Macro execution from C#.
However, if I make the Excel 2000 window visible to the user and also
keep the window in focus, the macros execute with their expected
speed. Again, the window must have focus or the macro slows to a
crawl again. Even in some instances Excel totally crashes out and I
lose my interface which in turn causes my .NET code to throw unhandled
exceptions. Not Good!
The Macros run in Excel are doing nothing more than finding some
Ranges, Copying some Rows, Inserting those Rows, and establishing some
Ranges. Nothing fancy at all.
I've spent a couple days trying to hash this out with no luck to this
point. I fear I'm experiencing a limitation of Excel 2000 vs. newer
versions. Can anyone confirm? Since at this point I'm just
attempting to make Excel 2000 work (forget newer versions for the
moment), Early vs. Late Binding should not be an issue. I would also
rather not pull this Macro code into C# for several reasons. Not
saying I won't if that indeed proves to be a solution.
Thanks for reading and for your time. Any help is much appreciated!
data and run Macros in an Excel spreadsheet. This works absolutely
flawlessly in conjunction with Excel XP (2002) or Excel 2003 using the
Office XP PIAs. Excel remains completely hidden from the user (the
way I want it) and I clean-up the COM objects and the Excel instance
when the routine completes. Nice and clean. The user has no idea
(visually) that Excel was ever opened.
Now management tells me they want to support Excel 2000 as well. Ok,
so I remove my references to the Office XP PIAs and replace it with a
reference to the Excel 9.0 TypeLib. Interops generate in VS and I'm
up and running.
Data population (writing values to ranges) works fine as it did
before. But when I call the necessary Macros in the Excel workbook
from C#, Excel seems to just hang... or execute very slowly. Taking
minutes to accomplish what previously took a fraction of a second.
Please remember, I'm not showing the Excel window to the user, it is
hidden.
Most, if not all, the KB docs on MSDN reference these procedures using
Excel XP (2002), Excel 2003, or Excel 2007, which is understandable
since these are the only versions for which PIAs are provided.
Needless to say, I cannot find anything specific to Excel 2000 on MSDN
regarding Macro execution from C#.
However, if I make the Excel 2000 window visible to the user and also
keep the window in focus, the macros execute with their expected
speed. Again, the window must have focus or the macro slows to a
crawl again. Even in some instances Excel totally crashes out and I
lose my interface which in turn causes my .NET code to throw unhandled
exceptions. Not Good!
The Macros run in Excel are doing nothing more than finding some
Ranges, Copying some Rows, Inserting those Rows, and establishing some
Ranges. Nothing fancy at all.
I've spent a couple days trying to hash this out with no luck to this
point. I fear I'm experiencing a limitation of Excel 2000 vs. newer
versions. Can anyone confirm? Since at this point I'm just
attempting to make Excel 2000 work (forget newer versions for the
moment), Early vs. Late Binding should not be an issue. I would also
rather not pull this Macro code into C# for several reasons. Not
saying I won't if that indeed proves to be a solution.
Thanks for reading and for your time. Any help is much appreciated!