Solved

Populating an MSWord document table from BCB

Posted on 2001-07-27
5
510 Views
Last Modified: 2011-04-14
I want to populate a table in a Word document from a BCB program.  The VBA fragment:

Dim MSWord As New Word.Application
Dim Doc As Word.Document

    Set Doc = MSWord.Documents.Add(Template:="C:\mytemp.dot",NewTemplate:False)
    Doc.Tables(1).Rows.Last.Cells(1).Range.Text = "some"
    etc..

...works fine as a Word macro, but I cannot get:

   MSWord = MSWord.CreateObject("Word.Application");
   Variant NewDoc = MSWord.OlePropertyGet("Documents").OleFunction("Add", "C:\\mytemp.dot",False);
   Variant Doc = MSWord.OlePropertyGet("ActiveDocument");
   Variant Tables = Doc.OlePropertyGet("Tables");
   Variant Table = Tables.OleFunction("Item" , 1);
   Variant Rows =  Table.OlePropertyGet("Rows");
   Variant Last =  Rows.OlePropertyGet("Last");
   Variant Cells = Last.OlePropertyGet("Cells");
   Variant Cell  = Cells.OleFunction("Item", 1);
   Variant Range = Cell.OlePropertyGet("Range");
   Range.OlePropertySet("Text", "some");

... to work at all.  The program halts at the "Variant Rows" line with an _ASSERTE dialog box and an "IsBound()" error.

Does anyone know an easy way to do this or where my error is?
0
Comment
Question by:TonyNJones
5 Comments
 
LVL 4

Expert Comment

by:AssafLavie
ID: 6326651
This is a C++ forum.
0
 

Author Comment

by:TonyNJones
ID: 6368309
This is a problem from C++ Builder;  where should I post this problem?
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6375448
My be use other metod:
...
TablePtr wordTable = WordApplication->ActiveDocuments-Tables->Item(1);
long m_Row = 1;
long m_Column = 2;
CellPtr wordCell = wordTable->Cell(m_Row,m_Column);
...
0
 
LVL 11

Expert Comment

by:griessh
ID: 6840249
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to refund the points and PAQ at zero points since nobody had an answer for you.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner

0
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 6857835
After review, the proposed answer will be accepted by:

ComTech
Community Support
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question