|
Our company has an created an ActiveX control using Visual Basic 6 that allows users to view TIFF images in a web page. When Office 2007 is installed, the error "component not correctly registered" shows up when this web page is loaded and the ActiveX control calls the AsyncRead function. We do not see this error when other versions of Office are installed; it will work just fine with Office 2000 and Office 2003. Also, the applications in Office 2007 do not need to be running for this error to occur.
I have tried removing the control from the Downloaded Program Files folder and downloading it again, but I am still getting the same error.
Any help would be appreciated.
|
|
|
|
|
Does the control have any dependency on any of the office components?
If so you may need to release a separate version of your control that works with Office 2007.
Otherwise try and install (register) your control after installing Office 2007.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)
|
|
|
|
|
I think your ActiveX control has dependency on Office 2003 Web component 1.1..If so then you need to update your ActiveX com.
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
I think your ActiveX control has dependency on Office 2003 Web component 11.0 ..If so then you need to update your ActiveX com.
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
i need to create a web interface to control (enter the multicast address, set playlist,start/stop streaming) the multicast settings of the windows media services, in server 2003.so that an admin can log in from any machine in the network and control the main streaming server.
it is for my project and its very urgent.
can anyone help me we it?some tell me to go with a COM, but i have no idea how to do it.any alternatives?please, im desperate.
thank you
|
|
|
|
|
Hi,
I hve just started learning COM. Can anybody suggest me some books, online tutorials etc.,
Thanks in advance
Sairam
|
|
|
|
|
|
Try this book:
Essential Com By Don Box
|
|
|
|
|
Hi All,
now I get connected in my main.cpp file to the server. I hope this will be correct. But how can I get now an event from the server? The server sends some events. I can see that because an Message Dialog will be opened from the server.
Now my questions are the following:
a)
Is the code until now correct? Is it possible to make a test if I get the correct connection or anything else?
b)
How can I get in the main.cpp an event (OnShowMessageDlg) or any message from the server? Do I need to add something to the sink class?
c)
Must I add something in the Sink class to get the an event in the invoke function? Or how should this work?
Let me know If you need any more information.
Once more, thanks for any help.
Juergen
main.cpp File
CComPtr<ICWOLE2> tCWOLE;
HRESULT hr;
hr = CoInitialize(0);
hr = CoCreateInstance(CLSID_CWOLEv2, 0, CLSCTX_LOCAL_SERVER, IID_ICWOLE2, (void**)&tCWOLE);
IConnectionPointContainer * pConnPtContainer;
hr = tCWOLE->QueryInterface(IID_IConnectionPointContainer,(void**)&pConnPtContainer);
if(FAILED(hr)){
CoUninitialize();
return false;
}
CComPtr<IConnectionPoint> ICPoint;
hr = pConnPtContainer->FindConnectionPoint(DIID_ICWOLEEvents,&m_pConnectionPoint);
if(FAILED(hr)){
CoUninitialize();
return false;
}
m_sink = new CSink;
LPUNKNOWN pUnk = NULL;
m_sink->QueryInterface(IID_IUnknown,(void**)&pUnk);
hr = m_pConnectionPoint->Advise(pUnk,&m_sink->cookie);
if(FAILED(hr)){
CoUninitialize();
return false;
}
pConnPtContainer->Release();
.
.
.
.
.
.
m_pConnectionPoint->Unadvise(m_sink->cookie);
m_pConnectionPoint->Release();
m_sink->Release();
CSink.h
class CSink : public ICWOLEEvents
{
public:
CSink::CSink() {m_refCount = 1, cookie = 0;}
CSink::~CSink() {}
STDMETHODIMP QueryInterface(REFIID riid, void ** ppvObj);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
STDMETHODIMP GetTypeInfoCount(UINT *iTInfo);
STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR **rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
STDMETHODIMP Invoke(DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags, DISPPARAMS* pDispParams,
VARIANT* pVarResult, EXCEPINFO* pExcepInfo,
UINT* puArgErr);
public:
int m_refCount;
DWORD cookie;
void OnShowMessageDlg(IMsgDlg *pIMsg, VARIANT_BOOL *Result);
};
CSink.cpp
HRESULT CSink::QueryInterface(REFIID riid, void ** ppvObj)
{
if (riid == IID_IUnknown){
*ppvObj = static_cast<void*>(this);
}
else if (riid == DIID_ICWOLEEvents){
*ppvObj = static_cast<ICWOLEEvents*>(this);
}
else if (riid == IID_IDispatch){
*ppvObj = static_cast<IDispatch*>(this);
}
else
{
char clsidStr[256];
WCHAR wClsidStr[256];
char txt[512];
StringFromGUID2(riid, (LPOLESTR)&wClsidStr, 256);
WideCharToMultiByte(CP_ACP, 0, wClsidStr, -1, clsidStr, 256, NULL, NULL);
sprintf(txt, "riid is : %s: Unsupported Interface", clsidStr);
*ppvObj = NULL;
return E_NOINTERFACE;
}
static_cast<IUnknown*>(*ppvObj)->AddRef();
return S_OK;
}
STDMETHODIMP_(ULONG) CSink::AddRef()
{
return ++m_refCount;
}
STDMETHODIMP_(ULONG) CSink::AddRef()
{
return ++m_refCount;
}
STDMETHODIMP_(ULONG) CSink::Release()
{
if (--m_refCount == 0)
{
delete this;
return 0;
}
return m_refCount;
}
STDMETHODIMP CSink::GetTypeInfoCount(UINT *iTInfo)
{
return E_NOTIMPL;
}
STDMETHODIMP CSink::GetTypeInfo(UINT iTInfo, LCID lcid,
ITypeInfo **ppTInfo)
{
return E_NOTIMPL;
}
STDMETHODIMP CSink::GetIDsOfNames(REFIID riid,
OLECHAR **rgszNames,
UINT cNames, LCID lcid,
DISPID *rgDispId)
{
HRESULT hr = E_FAIL;
return hr;
}
STDMETHODIMP CSink::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
WORD wFlags, DISPPARAMS* pDispParams,
VARIANT* pVarResult, EXCEPINFO* pExcepInfo,
UINT* puArgErr)
{
if ((riid != IID_NULL))
return E_INVALIDARG;
HRESULT hr = S_OK;
return hr;
}
void CSink::OnShowMessageDlg(IMsgDlg *pIMsg, VARIANT_BOOL *Result){
}
Test.idl
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: test_programm.exe
[
uuid(90B4344B-90CD-4527-BC00-4F4D45C793D6),
version(2.13),
helpstring("CW CWOLE")
]
library CW_CWOLE
{
importlib("stdole2.tlb");
interface ICWOLE2;
dispinterface ICWOLEEvents;
.
.
.
.
.
[
uuid(6775FB91-B5BE-11D6-A996-0050BA24C7B9),
version(1.1),
helpstring("Event dispatch interface for CW CWOLE")
]
dispinterface ICWOLEEvents {
properties:
methods:
[id(0x00000001)]
void OnConfigurationApply([in, out] VARIANT_BOOL* pAccept);
[id(0x00000002)]
void OnShowMessageDlg(
[in] IMsgDlg* pIMsg,
[out, retval] VARIANT_BOOL* Result);
};
typedef [uuid(5CBBA151-1C47-4D6C-B14C-C527E333F812), version(1.2)]
enum {
ECS_DEFAULT = 0,
ECS_FRONT = 1,
ECS_LEFT = 2,
ECS_RIGHT = 3,
ECS_LEFTUP = 4,
ECS_RIGHTUP = 5,
ECS_TOP = 6,
ECS_BACK = 7,
ECS_BACKLEFTUP = 8,
ECS_BACKRIGHTUP = 9,
ECS_BOTTOM = 10
} ECamSetup;
typedef [uuid(9545E3CA-6401-4418-A040-DA3A89E2C792), version(1.3)]
enum {
EPM_PERSP = 0,
EPM_ORTHO = 1,
EPM_2D = 2
} EProjectionMode;
[
uuid(F560F763-2948-11D7-A9BF-0050BA24C7B9),
version(2.13),
helpstring("CWOLE2")
]
coclass CWOLEv2 {
[default] interface ICWOLE2;
[default, source] dispinterface ICWOLEEvents;
};
|
|
|
|
|
Yes, you need to add code into the Invoke methods that looks at the dispid that's passed and maps that to the method you need to call. In addition, you need to unpack the parameter values from the struct pointed at by pDispParams.
Also, that thread needs to be in a window message dispatch loop - my understanding is that COM method calls are passed from other threads and processes into your thread using windows messages.
I know you can't/don't want to use ATL and I can totally understand that...but ATL does make this sort of thing REALLY easy
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
thanks a lot for your reply. Do you know if there will be an example about the invoke theme? I didn't know how this function will/must be called and how my functions then will be called / how I can get a message from the COM server above this invoke functions.
I know and I heared also from other people that it will be easier to work with ATL. But in this project I can't use ATL.
|
|
|
|
|
OK - the Invoke method is called when an event is raised by the server. It will tell you which method it's calling using the dispidMember parameter. The parameters to the call will be in the structure pointed at by pdispparams. You can pass back a result in pvarResult.
So, you could implement your Invoke using a switch statement and parameter transformation like this:
STDMETHODIMP CSink::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
WORD wFlags, DISPPARAMS* pDispParams,
VARIANT* pVarResult, EXCEPINFO* pExcepInfo,
UINT* puArgErr)
{
if ((riid != IID_NULL))
return E_INVALIDARG;
HRESULT hr = S_OK;
switch (dispIdMember)
{
case 1:
if (pDispParams->cArgs != 1) return E_INVALIDARG;
if (V_VT(&pDispParams->rgvarg[0]) != VT_BOOL|VT_BYREF) return E_INVALIDARG;
OnConfigurationApply(V_BOOLREF(&pDispParams->rgvarg[0]));
break;
case 2:
break;
}
return hr;
}
HTH!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The problem I have before is that the Invoke Function will not be called. What must I do that this function will be called from the Server when an event is raised?
I can see that an event is raised from the server because an dialog will be opended. But the invoke function will not be called.
|
|
|
|
|
Your code all looks reasonable - I presume you've set a breakpoint in your Invoke method to see if it gets called?
I'd also set breakpoints on your AddRef, QueryInterface methods and see if they get called when you call the connection point's Advise method - that's how you tell the server about your event handler.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I set now also some breakpoints in the AddRef and QueryInterface Methods. These methods will be called. Only the Invoke function will not be called.
Do you know what I can do to test if I did something wrong or if the COM server works correct?
|
|
|
|
|
Suddenly realised what your problem could well be.
The server could be asking for your event handler's dispinterface methods by name - in which case you would need to implement GetIDsOfNames.
Or it could be asking for your class's type-information, in order to determine what methods and associated parameters are available. I think you need to investigate (with breakpoints) whether the othe r IDispatch methods are called. If they are, then as you don't implement them, the server will (as a result) decide not to call your IDispatch::Invoke method.
All these details, and the pain of implementation, are why I use ATL - I fully accept that you can't use ATL - I sympathize with your predicament!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I tried it now with the breakpoints. The functions QueryInterface / AddRef and Release (IUnknown) will be called. But all the four IDispatch methods (GetTypeInfoCount / GetTypeInfo / GetIDsOfNames / Invoke) will not be called. So now if I understood you correct, I must implement (call the method) GetIDsOfNames by myself?
I tried the implementation of the method GetIDsOfNames a little bit but my application crashed down anytime. Please give me a note if I understood you correctly that the solution must be to implement this function. If so, I must search for some better examples about that and try it again.
Thanks for your help.
|
|
|
|
|
Have a look more closely at what interfaces are being asked for in QueryInterface. The fact that your IDispatch methods aren't being called means that implementing GetIDsOfNames isn't going to help - you need to work out what the server's actually trying to access on your event handler object.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart, thanks for your help. Now it seems to work. The problem was that the Connection (Advise) must be done before I open the programm. If I do this Advise after the program start I didn't get any events.
|
|
|
|
|
Hi ,
Is there any way to update the DOM(view source ) of IE browser by using
IHTMLDocument and IHTMLElement interface. I want to change page's title,tooltip in browser before displaying it in IE browser.
Thanks
Atul
|
|
|
|
|
Hi,
I am using following imports:
//Mircorsoft Office Objects
#import \
"C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE12\mso.dll"\
rename("DocumentProperties", "DocumentPropertiesXL")\
rename("RGB", "RBGXL")
//Microsoft VBA Objects
#import \
"C:\Program Files (x86)\Common Files\Microsoft Shared\VBA\VBA6\vbe6ext.olb"
//Excel Application Objects
using namespace Office;
#import "C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE"\
rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL")\
rename("DocumentProperties", "DocumentPropertiesXL")\
rename("ReplaceText", "ReplaceTextXL")\
rename("CopyFile", "CopyFileXL")\
exclude("IFont", "IPicture") no_dual_interfaces
Excel::_ApplicationPtr XL;
Excel::_WorkbookPtr book;
Excel::_WorksheetPtr sheet;
By using for loop ,able to get all workbook names.Using following code iterating through item, getting all workbook names.
book = XL->Workbooks->Item[1];
In case of worksheet, i am not getting the name of worksheet.There is no such option as workbook.
Able to point to particular sheet, but name option is not there.
sheet = XL->Workbooks->Item[1]->Sheets->Item[1];
I want to retrieve whole list of worksheets present in workbook.
Googled but I didn't get any clue.
If there is any option, please give me clue.
Thanks in advance.
Gtag.
|
|
|
|
|
gtag wrote: Able to point to particular sheet, but name option is not there
Yes it is. This code compiles and builds and runs:
Excel::_WorkbookPtr wb = xl->Workbooks->Add();
Excel::_WorksheetPtr ws = wb->Worksheets->Item[1];
if (ws)
std::cout << ws->Name << std::endl;
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
Thanks again.
But I am not getting name its failing at getting sheets from the workbook to which I am pointing.
Main aim is to get the workbook names and worksheets names opened by the user, might be 50 workbooks or any number.
Please check the code and let me know where I am doing wrong?
//MicroSoft Office Objects
#import \
"C:\Program Files\Common Files\Microsoft Shared\OFFICE11\mso.dll" \
rename("DocumentProperties", "DocumentPropertiesXL") \
rename("RGB", "RBGXL")
//Microsoft VBA Objects
#import \
"C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\vbe6ext.olb"
using namespace Office;
//Excel Application Objects
#import "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" \
rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL") \
rename("DocumentProperties", "DocumentPropertiesXL") \
rename("ReplaceText", "ReplaceTextXL") \
rename("CopyFile", "CopyFileXL") \
exclude("IFont", "IPicture") no_dual_interfaces
using namespace std;
#include <string>
int _tmain()
{
Excel::_ApplicationPtr XL;
Excel::WorkbooksPtr book;
Excel::WorksheetsPtr sheet;
string BookName;
string SheetName;
int BookCount;
int SheetCount;
string bookArray[20];
int count;
//A try block is used to trap any errors in communication
try
{
//Initialise COM interface
CoInitialize(NULL);
HRESULT hr = XL.GetActiveObject(L"Excel.Application");
if(SUCCEEDED(hr))
{
book = XL->Workbooks;
BookCount = book->Count;
for(int i=1;i<=BookCount;i++)
{
BookName = book->Item[i]->Name;
cout<<BookName<<endl;
SheetCount = book->Item[i]->Sheets->Count;
for(int j=1;j<SheetCount;j++)
{
sheet = book->Item[i]->GetWorksheets();
if(sheet)
{
Excel::_WorksheetPtr pSheet = sheet->Item[j];
SheetName = pSheet->Name;
cout<<SheetName<<endl;
}
}
}
}
}
catch(_com_error &error)
{
//cout << "COM error " << endl;
}
}
gtag
modified on Friday, October 2, 2009 12:24 PM
|
|
|
|
|
gtag wrote: Excel::WorksheetsPtr sheet;
Should be Excel::SheetsPtr sheet;
gtag wrote: Excel::_WorksheetPtr pSheet = sheet->Item[j];
Not all sheets are worksheets. This line can raise an exception as well if, for example, you have a chart sheet. So, you should use this code:
sheet = book->Item[i]->Sheets;
if(sheet)
{
try {
Excel::_WorksheetPtr pSheet = sheet->Item[j];
SheetName = pSheet->Name;
cout<<SheetName<<endl;
}
catch (_com_error&) { cout << "Sheet " << j << " is not a worksheet\n"; }
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi stuart,
Thanks again.
I corrected, its working perfectly.
One more help I need, I just want to know , is there any documentation on excel for programming in C++ , I have checked msdn, codeproject, there are only basic things related to excel not at events level.
If there are any, please provide me the link where I get the info. Or if you have any such stuff on excel(writing excel events etc), please let me know.
Regards,
Gtag
|
|
|
|
|