I am writing a program to clean excel files from empty rows and columns, i started from my own question Fastest method to remove Empty rows and Columns From Excel Files usin
I found a solution, but i will accept other working answers
When passing an empty string as password the excel consider it as nothing. So it ask for a password and show the dialog.
The solution is to pass a single quotation as a password, excel will consider it as empty string. If workbook is not password protected it will open, else it will throw the following exception
The password you supplied is not correct. Verify that the CAPS LOCK key is off and be sure to use the correct capitalization
The code will be:
m_xlWrkb = m_xlWrkbs.Open(strFile, Password:="'")
Note
In microsoft excel, single quotation on the beginning of a value is used to force text formatting.
example; '0 is readed as a text of value 0