Hey all,

I have recently become interested in trying to automate various MS Office applications using C++... I was writing some macros in Excel to update some databases that I work with, and decided it would be cool if I could sort of wrap the entire process in a C++ application. (This way I could accomplish a variety of other things from the same application. But regardless, the reasons why I want to do this are both practical and for personal satisfaction)

Anyway, this is more of a personal problem/project that I am working on, so there is no pressure ;)

Heres the thing: I have pretty much no experience working with COM objects...So I am taking this rather slowly. First thing I want to do is actually open an instance of Excel via C++.

But just my luck, the documentation on the subject is rather skimpy or out of date, and msdn is cryptic as always (again, I'm am no expert on the subject, so msdn is really no use to me).

Anyway, to the meat of my post. I have two questions for you:

1) The documentation that I did find had some code examples. Almost all the examples indicated I would need to import the MSO.DLL, among others. So I added the import line (note I also copied the mso.dll to the same directory as my program so that I wouldn't have to specify the entire path, and so that if I change machines the application will still have all the necessary dlls and such), but in doing so my compiler spat out massive errors (from just importing the library...) I have no idea what they are caused by... They are clearly connected to the MSO.DLL. Incidentally, I am using Dev-C++, if it makes any difference...

Oh yea, the errors are mostly "stray" errors....e.g. stray '\144' in program (the errors occur in the mso.dll)

2) Does anyone know of any resources that they could point me to for some help? I'm thinking I might need to get a book on the subject, so if anyone knows of any that are particularly good, that would be really great.

Thanks a lot guys!

cheers,

n1337

*sigh* not even a single response...perhaps I should try a different forum?

Regardless, I remain hopeful...bump!

One last desparate bump before I let this die...

The #import directive with Dev C++ is not doing what you expect, practically it is the same as #pragma once i.e. related to include guards instead of type library imports. See e.g. http://www.delorie.com/gnu/docs/gcc/cpp_54.html

If you really want to tackle Office automation, you could switch from Dev C++ to a free edition of Visual C++ or Borland's C++ Builder to continue with.

As to your second question, I simply don't know of any good resources regarding Office automation & C++. Maybe google is a good bet to continue with.

I was afraid it was an IDE issue...I just always thought that Visual C++ was somewhat bloated...In any case, I'll give it a try.

TY very much for your help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.