|
Hello,
I have written automation to start excel charts but the createdispatch doesnt start excel
_Application app;
if(!app.CreateDispatch(CreateDispatch("Excel.Application")
{
AfxMessageBox(
"Couldn't start Excel and get an application 0bject");
return;
}
wht can be the problem
Prithaa
|
|
|
|
|
prithaa wrote: if(!app.CreateDispatch(CreateDispatch("Excel.Application")
This is both syntactically wrong and just plain weird looking. How about:
COleException e;
if (! app.CreateDispatch("Excel.Application", &e))
... prithaa wrote: wht can be the problem
Did you remember to call AfxOleInit() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hello
Oh sorry CreateDispatch was written twice
I wrote
if(!app.CreateDispatch("Excel.Application"))
{
AfxMessageBox("Couldn't start Excel and get an application 0bject");
return;
}
The above is not working
Prithaa
|
|
|
|
|
prithaa wrote: The above is not working
Why not? Are you looking at the exception object (specificaly it's getter method) like I suggested?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hello
Yes still excel doesnt start
COleException e;
if(!app.CreateDispatch("Excel.Application",&e))
{
AfxMessageBox("Couldn't start Excel and get an application 0bject");
return;
}
i wrote the above
|
|
|
|
|
Did you somehow think that simply creating the object would make it all better? What's the "value" of e ?
What type of object is app ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
it is like this
_Application app;
e is not initialised
|
|
|
|
|
Ok, and how did you go about creating the _Application class? In other words, how did you import it from Excel's type library? See the latter part of this article for one way.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I have include the type library through class wisard automation
and
#include "excel.h"
on top of the file
|
|
|
|
|
i need not write the import command since i have already included through
automation type library
isnt it
|
|
|
|
|
Correct. There are two ways of getting access to Excel's COM interface.
If you look at the COleException object when CreateDispatch() fails, does it hint that the COM library has not been initialized?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
In the watch window the value of e doesnt change even after the function is called
|
|
|
|
|
prithaa wrote: In the watch window the value of e doesnt change
It's created on the stack so why would it change? You have to call it's GetErrorMessage() method.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
When i call the GetErrorMessage() the string is blank
LPTSTR f;
e.GetErrorMessage(f,0);
f is blank
|
|
|
|
|
Of course it is! You've not only given it an invalid buffer, you said the buffer's size is 0.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
when i give 50 or 100 it gives me debug assertion failed
|
|
|
|
|
And rightly so since you've given it an invalid buffer. Did it ever occur to you to check here? As this is all elementary stuff, I'm thinking Excel Automation might just be a bit beyond your current skillset.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
sorry i didnt check the documentation
i m getting the following error
coinitialise has not been called
|
|
|
|
|
prithaa wrote: i m getting the following error
coinitialise has not been called
I knew this thread was about 15 posts too long. See here. Since you did not answer, I just assumed you had it right and the problem was elsewhere.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
i think it will be done
thnk you
|
|
|
|
|
Hi there,
Is it posible, using vs2008 express, to copile a c++ application (not managed c++).
I don't want a .NET application.
Can that be done? How?
Thanks!
|
|
|
|
|
Hi,
SummerBulb wrote: Is it posible, using vs2008 express, to copile a c++ application (not managed c++).
Yes.
SummerBulb wrote: Can that be done? How?
Simple tutorial -> here[^].
You can find more tutorials by googling.
Nuri Ismail
|
|
|
|
|
I think you might have misunderstood my.
I know how to write c++ code. I also know how to write code in VS2008.
What i am looking for is a way to write code in VS2008 express and compile it using the regular c++ compiler, and not using the managed c++ compiler that comes with the VS2008 express IDE.
Or am i missing something here?
|
|
|
|
|
Hi,
The C++ compiler in VS2008 Express (and other editions) is not a managed compiler. It is regular C++ compiler. For managed C++ there is a C++/CLI . So when you set your project type to Visual C++ , this means that you will use unmanaged C++ compiler.
I hope this helps.
Regards,
Nuri Ismail
|
|
|
|
|