Solved

Populating an MSWord document table from BCB

Posted on 2001-07-27
5
507 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

803 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