问题
Show message of Com error 800a03ec when i can PrintPreview() of workbook
m_spWorkbook->PrintPreview();
i get m_spWorkbook in the following code:
hr = spOleObject->QueryInterface(__uuidof(_Workbook), (void**)&m_spWorkbook);
what's the problem?
回答1:
Exception 800a03ec often means problem with locale. For example, language in Excel differs from regional settings. Have a look at these links:
- http://blogs.msdn.com/b/eric_carter/archive/2005/06/15/429515.aspx
- http://support.microsoft.com/kb/320369
As I understood from your other question, HRESULT 0x800a03ec throwing may be assotiated with instances of Excel. Perhaps, in moment, when you are calling printPreview
application is already closed or you are trying create additional instance of Excel or user editing in your instance of Excel
回答2:
I'm not sure, but this may have to do with Security Permissions. My hunch would be (I haven't tested this specifically), that PrintPreview
internally uses macro functions or is trying to get access to VBA Project model; either of which may be denied if the macro security is set to default level (or higher!).
Try giving VBA Macros "Enable all macros" security level to see if this solves the problem. If it does then you will probably want to have a signed application whose certificate is trusted by VBA in production environment. Or you can lower VBA security on all involved computers but of course that isn't recommended at all.
来源:https://stackoverflow.com/questions/5377069/com-error-800a03ec-when-i-call-printpreview-method-of-workbook