Solved

Populating an MSWord document table from BCB

Posted on 2001-07-27
5
503 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
Comment Utility
This is a C++ forum.
0
 

Author Comment

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

Expert Comment

by:AlexVirochovsky
Comment Utility
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
Comment Utility
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
Comment Utility
After review, the proposed answer will be accepted by:

ComTech
Community Support
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now