Error with OLE server

A

Aleksander

Hello,
I am working with OLE server using C++ Builder 6.0, the code is the following:

{
Variant Word, Document, Table, Cell;
int RowCount, ColCount;

Word = CreateOleObject("Word.Application.8");
Word.OlePropertySet("Visible", true);
Word.OlePropertyGet("Documents").OleProcedure("Add");
Document = Word.OlePropertyGet("Documents").OleFunction("Item", 1);
Table = Document.OlePropertyGet("Tables").OleFunction("Add", Document.OleFunction("Range", 0, 0), 5, 5);
RowCount = Table.OlePropertyGet("Rows").OlePropertyGet("Count");
ColCount = Table.OlePropertyGet("Columns").OlePropertyGet("Count");
for (int i=1; i <=RowCount; i++)
for(int j=1; j <=ColCount; j++) {
Cell = Table.OleFunction("Cell", i, j);
Cell.OlePropertyGet("Range").OleProcedure("InsertAfter", WideString(IntToStr(i)) + WideString("-") + WideString(IntToStr(j)));
}
Document.OleProcedure("SaveAs", ChangeFileExt(Application->ExeName, ".doc"));
Word.OleProcedure("Quit");
}

Under Windows XP Home Edition with Microsoft Word 2003 Standart Edition for Students and Teachers the Application gets an error
"Exception occured". Under Windows 2000 and Windows XP Pro with Microsoft Word 2003 everything is normal. What can be the reason?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Error with OLE server 4

Top