Doing Office recently added to identify and remove the watermark of ATL COM components, PPT and WORD has been completed, but EXCEL when Open the file COM x800ac472 returned HRESULT is 0, the parameters of the Open, except for the file name of the other parameters are tuned into missingtype, but still error, occasionally will collapse, but try not exception,
Open the EXCEL code is as follows:
CComBSTR bstrFilePath (lpwszFilePath);
CComVariant varUpdateLinks (2);
CComVariant varTrue (VARIANT_TRUE);
CComVariant varFalse (VARIANT_FALSE);
CComVariant varMissingType ((long) DISP_E_PARAMNOTFOUND);
VarMissingType. N=VT_ERROR;
LCID lcidSys=GetSystemDefaultLCID ();
LCID lcidUsr=GetUserDefaultLCID ();
M_spWorkbook. Release ();
Retrieves the hr=S_OK;
Try
{
Hr=m_spWorkbooks - & gt; Open (
BstrFilePath,
VarMissingType,//update the specified file link in the way, if you omit this parameter, then prompt the user to specify the link way of updating, if Microsoft Excel are open WKS, WK1 or WK3 format file and UpdateLinks parameters to 2, the Microsoft Excel, according to the pattern formation was associated with the file chart if this parameter is zero, does not create any chart,
VarMissingType,//if it is True, in read-only mode, open the workbook,
VarMissingType,//if Microsoft Excel are open a text file, then this parameter specifies the delimiter, if you omit this parameter, use the current separator,
VarMissingType,//a string that contains the open workbook needs to be protected by password, if you omit this parameter and workbook has a password, and then prompt the user for a password,
VarMissingType,//a string that contains the write workbook needs to be protected by password, if you omit this parameter and workbook has a password, and then prompt the user for a password,
VarMissingType,//if it is True, do not let Microsoft Excel displays read-only recommended message (if the workbook in "read-only recommended" option to save),
VarMissingType,//if the file is a text file, then this parameter is used to indicate the file from which the operating system (in order to correct the mapping code pages and carriage return/line breaks (CR/LF)),
VarMissingType,//if the file is a text file and 6 of the Format parameters, then this parameter is a string, designated as a delimiter characters,
VarMissingType,//if the file is Microsoft Excel add-ins 4.0, then this parameter is True, can open the add-ins to make it visible in the window, if this parameter is False or omitted, the open load in hidden ways macros, and cannot be set as visible,
VarMissingType,//when files cannot be opened in read/write mode, if this parameter is True, can add the file to the file notification list, Microsoft Excel in read-only mode to open the file and polling notification list, and issued a notice to the users of the file is available, if this parameter is False or omitted, it does not request any notice, and can't open any file is not available,
VarMissingType,//open the file when the trial of the index of the first file converter, the first trial is the specified file converter; If the translator does not recognize this file, try all other converter,
VarMissingType,//if it is True, then the workbook to add to the list of most recently used files, the default value is False,
VarMissingType,//if it is True, then with Microsoft Excel (including control panel) language save the file, if False (default), with Visual Basic for Applications (VBA) (Visual Basic for Applications (VBA) : macro language version of Microsoft Visual Basic, for writing Applications based on Microsoft Windows, built into multiple Microsoft Applications,) save the file, the language of Visual Basic for Applications (VBA) usually in the form of the English version
VarMissingType,//if you do not specify any value, then the default behavior for common loading is
LcidUsr,//I don't know this parameter has a purpose, but others say can be set to 0
& M_spWorkbook
);
}
The catch (_com_error & amp; E)
{
Return OFFICEWATERMARK_ERROR_INIT_COM_EXCEPTION;
}
The catch (... )
{
Return OFFICEWATERMARK_RETURN_FAILED;
}
If (FAILED (hr) | | m_spWorkbook==NULL)
{
Return OFFICEWATERMARK_ERROR_FILE_OPEN;
}
Still hope people
CodePudding user response:
Look at the others DLL code is generated by the MFC project, Workbooks. Open the parameters and I also do not have what distinction,Then check the excel VBA development document and Workbooks. The Open method is introduced, the inside of the parameters described, all parameters are optional,
In the parameter in the file name, the rest is transferred into MissingType after still couldn't open the Excel file, suspected to be related to environment, but I'm the local installation of Excel can be double-clicked and edit documents,
Don't know if I hadn't to create the Application parameters, create Excel Application code is as follows:
HRESULT hr=m_spApp. CoCreateInstance (OLESTR (" Excel. Application "), NULL, CLSCTX_SERVER);
The returned HRESULT is successful,
CodePudding user response:
Find out why theOpen the EXCEL file HRESULT return 0 x800ac472 because I use EXCEL without authentication, so software to open the wizard window will pop up a activation,
This time, if continue operation Excel Application returns the 0 x800ac472 error,
So SAO years, darling still with the original
CodePudding user response:
Or...//close the activation window callback
BOOL CALLBACK CloseWindowCallback (HWND HWND, LPARAM LPARAM)
{
WCHAR wszTitle [512].
LPCWSTR lpwszAuthWinName=(lParam LPCWSTR);
GetWindowText (HWND wszTitle, sizeof (wszTitle));
if (! _wcsicmp (wszTitle lpwszAuthWinName))
{
: : SendMessage (HWND WM_CLOSE, 0, 0);
return FALSE;
}
Return TRUE;
}
Int main ()
{
WCHAR lpwszAuthWinName []=L "Microsoft Office activation wizard";
The return! EnumWindows (CloseWindowCallback, (LPARAM) lpwszAuthWinName);
}