Solved

Populating an MSWord document table from BCB

Posted on 2001-07-27
5
516 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Title # Comments Views Activity
Quicksort a dynamic deque 33 79
Fast, free, private online code repository / editor 7 113
How to convert MFC APP to Win32 APP. 19 112
why doesn't assert terminate here? 2 11
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

697 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