MS Office Forum / Word / Programming / February 2007
Error with OLE server
|
|
Thread rating:  |
Aleksander - 06 Feb 2007 11:55 GMT 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?
Perry - 06 Feb 2007 22:29 GMT Try to replace Word = CreateOleObject("Word.Application.8");
by Word = CreateOleObject("Word.Application");
Krgrds, Perry
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?
Aleksander - 06 Feb 2007 23:13 GMT I tried this, it didn't help. Try to replace Word = CreateOleObject("Word.Application.8");
by Word = CreateOleObject("Word.Application");
Krgrds, Perry
"Aleksander" <avpetrov@online.ru> wrote in message news:ejueDWeSHHA.2188@TK2MSFTNGP03.phx.gbl... 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?
Perry - 06 Feb 2007 23:13 GMT Was worth a try. Suggest you to address the apprpriate newsgroup for C++ or wait for someone else to help you in this newsgroup.
Good luck! Perry I tried this, it didn't help. "Perry" <drumper@gmail.com> wrote in message news:64113D6E-C0D2-43F2-8310-F7A9FECCBA9B@microsoft.com... Try to replace Word = CreateOleObject("Word.Application.8");
by Word = CreateOleObject("Word.Application");
Krgrds, Perry
"Aleksander" <avpetrov@online.ru> wrote in message news:ejueDWeSHHA.2188@TK2MSFTNGP03.phx.gbl... 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?
Aleksander - 07 Feb 2007 10:38 GMT "Suggest you to address the apprpriate newsgroup for C++", could you name any one? Was worth a try. Suggest you to address the apprpriate newsgroup for C++ or wait for someone else to help you in this newsgroup.
Good luck! Perry "Aleksander" <avpetrov@online.ru> wrote in message news:eViO9OkSHHA.4404@TK2MSFTNGP03.phx.gbl... I tried this, it didn't help. "Perry" <drumper@gmail.com> wrote in message news:64113D6E-C0D2-43F2-8310-F7A9FECCBA9B@microsoft.com... Try to replace Word = CreateOleObject("Word.Application.8");
by Word = CreateOleObject("Word.Application");
Krgrds, Perry
"Aleksander" <avpetrov@online.ru> wrote in message news:ejueDWeSHHA.2188@TK2MSFTNGP03.phx.gbl... 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?
|
|
|