开发者

Issue with an example in "How to transfer data to an Excel workbook "

http://support.microsoft.com/kb/306023 it's the first example: "Use Automation to Transfer Data Cell by Cell" Below are the variables I declared for the example.

Excel.Application m_objExcel;
Excel.Workbooks m_objBooks;
Excel._Workbook m_objBook;
Excel.Sheets m_objSheets;
Excel._Worksheet m_objSheet;
Excel.Range m_objRange;
string m_strSampleFolder =开发者_如何学Python @"C:\VBtest\PRACTICEProgramming\INDIVIDUALprograms\EXCEL";
string m_objOpt = @"C:\VBtest\PRACTICEProgramming\INDIVIDUALprograms\EXCEL";
Excel.Font m_objFont;

Basically everything runs fine. The issue is when the app is running, I get an error message.

"COMException was unhandled

Excel cannot access 'EXCEL'. The document may be read-only or encrypted."

I'm thinking the value I declared for m_objOpt is declared wrong or it doesn't like the value. I tried creating a premade .XLS file but that doesn't work. I also tried putting a name for the xls but the add method wants to find the xls in the default path which I don't want.

I don't know what I can do to fix it.


Looks like you're missing the file extension at the end of m_objOpt... You can try to add .xls or .xlsx to it, or something else regarding the file extension.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜