DISP_E_UNKNOWNNAME from GetIDsOfNames
-
Hi, I getting the above return code the following is my code sequence
CLSID clsid; // initialization
HRESULT hr = CLSIDFromProgID(L"Excel.Application",&clsid)IDispatch *pWApp;
hr = CoCreateInstance(clsid, NULL, CLSCTX\_LOCAL\_SERVER, IID\_IDispatch, (void \*\*)&pWApp);
LPOLESTR ptName = (LPOLESTR) _T("OpenText");
DISPID dispID;
hr = pWApp->GetIDsOfNames(IID_NULL, &ptName, 1 , LOCALE_USER_DEFAULT,&dispID);I am using VIsual C++ 6.0 excel 2003 Thanks
-
Hi, I getting the above return code the following is my code sequence
CLSID clsid; // initialization
HRESULT hr = CLSIDFromProgID(L"Excel.Application",&clsid)IDispatch *pWApp;
hr = CoCreateInstance(clsid, NULL, CLSCTX\_LOCAL\_SERVER, IID\_IDispatch, (void \*\*)&pWApp);
LPOLESTR ptName = (LPOLESTR) _T("OpenText");
DISPID dispID;
hr = pWApp->GetIDsOfNames(IID_NULL, &ptName, 1 , LOCALE_USER_DEFAULT,&dispID);I am using VIsual C++ 6.0 excel 2003 Thanks
-
For CoInitialize I am getting a 0x00000001 S_FALSE (already initliazed) For CLSIDFromProgID I am getting a 0x00000000 S_OK For CoCreateInstance I am getting a 0x00000000 S_OK For GetIDsOfNames I am getting a 0X80020006 DISP_E_UNKNOWNNAME Thanks
I have tried this code with a variety of names (supposedly in Excel) but get the same response each time. The MSDN documentation is not very helpful so I'm not sure where to go from here. However, once again I would ask, what problem are you actually trying to solve?
-
For CoInitialize I am getting a 0x00000001 S_FALSE (already initliazed) For CLSIDFromProgID I am getting a 0x00000000 S_OK For CoCreateInstance I am getting a 0x00000000 S_OK For GetIDsOfNames I am getting a 0X80020006 DISP_E_UNKNOWNNAME Thanks
-
I just tried again with the name "worksheets" and it worked. So, the code is correct, but the name you are using is not.
Very good you are right on the key is the first paramter _In_ LPCOLESTR lpszProgID, The Class id name, Excel is divded into for objects Application, Workbook, Worksheet, and I think Range In Visual C++ 6.0 there is a OLE/COM viewer which might kind a hint of the names What I am trying to do, My boss gave me an assignment to automate the pasting of .txt file onto a Excel Worksheet I wanted this app to be MFC based as I might need to employ windows services Hence the main thread CWinApp and associated mainwindow Thanks again for your help
-
Very good you are right on the key is the first paramter _In_ LPCOLESTR lpszProgID, The Class id name, Excel is divded into for objects Application, Workbook, Worksheet, and I think Range In Visual C++ 6.0 there is a OLE/COM viewer which might kind a hint of the names What I am trying to do, My boss gave me an assignment to automate the pasting of .txt file onto a Excel Worksheet I wanted this app to be MFC based as I might need to employ windows services Hence the main thread CWinApp and associated mainwindow Thanks again for your help
-
A quick search for "Excel C++" finds Accessing Excel Spreadsheets via C++[^].
Richard, I have to wait for years here to get a better compiler e.g. Visual Studio However Visual C++ 6.0 has an OLE/COM viewer So...... From File -> Run the Registry Editor Then get the progid http://msdn.microsoft.com/en-us/library/aa911706.aspx[^]
-
A quick search for "Excel C++" finds Accessing Excel Spreadsheets via C++[^].
-
I am going to go with the method you pointed out had using AS i GET BY THE DISP_E_UNKNOWN Maybe the way excel was installed it ddn't make entries for HKCR\Typlib for the excel methods properties Thanks
-
You can find (most of?) the names in the Excel object properties[^]; I don't know where you got "OpenText" from.
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.opentext(d=printer,v=office.11).aspx[^] When I orignally coded the app and used the #import method I didn't find which led me to use native OLE functions Then I got stuck with GetIDSofnames Now I found the api in my excel.h header must of overlooked thanks