ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook.Open failure (https://www.excelbanter.com/excel-programming/309482-workbook-open-failure.html)

Josh Orfanakis

Workbook.Open failure
 
I have a bunch of Excel files which I need to open and make some
formatting changes for printing.

There are a handful for which the Open method is failing.
The error info from the exception has proven to be useless. For most
when I open the file by hand in Excel there are various dialogs that pop
up. I figured this must be the reason. There is one dialog asking about
whether or not to enable/disable macros. There is one suggesting I open
read-only unless I need to make changes and lastly there are few that
pop up a password box.

The password ones are no problem. I understand the failure.

But what about the others? I tried setting EnableEvents to false and
DisplayAlerts to false but this did not make a difference.

I am using the COM interface to Excel 2000. I have been able to
translate most VB examples to my C++ but it is possible the
DisplayAlerts is not quite correct. The DisplayAlerts property is an
array of VARIANT_BOOL. The PutDisplayAlerts method takes a long lcid and
a VARIANT_BOOL. I am guessing lcid is an index. Which indices should I
set? Right now I am just guessing at 0. The GetDisplayAlerts just
returns VARIANT_BOOL. Huh?

Is there documentation on these methods anywhere? I am using C++ but I
do have VS.NET so I should have access to VB for reference. VB is not an
option for the application as this is only a part of a much larger C++
application.

Basically what I want to do is open the file with no user interaction,
select all rows/columns and call autofit, change all background to white
text to black and that is it. I need as little user interaction as
possible, like zero if possible.


Any help appreciated
TIA

JO


All times are GMT +1. The time now is 12:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com