Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OStream

Status
Not open for further replies.

Sidro

MIS
Sep 28, 2002
197
0
0
US
hi,

In C++ I can write to a text file using the ofstream.
for example:

void main()
{
ofstream Outfile(data.txt);
int number=1800;

Outfile>>number;

}
Now instead of writing to a text file, how would I write to
lets say microsoft word file or microsoft excel? Anyone tried it? thanks in advance!
 
Now you are talking about automation. It is a whole different ball game. You need either a MFC project, or an ATL project with MFC support. You need to use MFC it import the appropriate library as a class. Then you can invoke the methods.

Let me know if you need more info.
 
Hi Cathym,
Thanks for your response. Do you have an example or is there a book that teaches how to do these kinds of stuff other than the basic C++ programming?
 
I have been using the wrox series of books, starting with begining C++ through Professional ATL COM Programming. The is also information in the MSDN knowledge base.

To get you at least started, on the menu of C++ use file, and new. Not the icon. You will get a dialog box. On the project tab, use either the MFC AppWizard, or the ATL COM AppWizard. If you use ATL COM, you will also need MFC Support. Be sure to check the box for automation during the wizard steps. After your project is set up, press ctl W for. You will get a dialog box for MFC. You need to add a class for a type library. It will take you through the steps. You do not need to include everything in the library, just the items you will be using. After the files are created (excel9.cpp and excel9.h) be shure to include the header file in the file you are writting your code.

This sounds more scary than it is. This also lets you get excel to do almost anything, things excel cannot do on its own.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top