LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Word table formatting functions missing in the Word Report library

I am developing a Word procedure using the Word Report library
functions to capture and report test results from an automated test
using Labwindows. I was able to go as far as opening the document,
displaying headers and section titles as well as tables. When I saved
the document, I found that the table borders and grids were not
displayed. I searched the library and couldnt find any formatting
functions in the Word Report library. I did locate a table border
formatting function in the word2000demo example, but I couldnt figure
out how to integrate this functionality into my exisiting Word Report
functions. Has anyone been able to do this and are there any examples
of anyone accomplishing this. Again, I have seen the example, but I
can not seem to get this functionallity integrated into what I have
developed so far using the Word Report functions. I would appreciate
any help.

0 Kudos
Message 1 of 3
(3,463 Views)

Hi Mike,

First off, I wanted to mention that the way LabWindows/CVI talks to Microsoft Word is done through ActiveX.  All those Word examples you see with LabWindows/CVI are using an ActiveX generated wrapper (we created that wrapper which is either
Word2000.fp or Word97.fp and shipped it with LabWindows/CVI).  Now of course, we didn't include all the Microsoft Word methods and properties so if you find that you are missing something, you will need to generate your own wrapper via the ActiveX Controller Wizard.  Also, as later versions of Microsoft Word come out, if you decide you would like to use the some of the newer methods and properties, you might need to regenerate the wrappers.  For some additionally references, check out this post in which I responded to another customer with some additionaly helpful links.

To address your question, I am glad you found the section in the Word2000example which is formatting the tables (around line 673 in the AddTableToDoc function). Essentially what you need to do is get a handle to the table object and then to the borders object. At that point, you can use the Get/Set Properties to format the borders. For example, if you had a handle to the document (
docHandle), then you could say

caErrChk (Word_GetProperty (docHandle, NULL, Word_DocumentTables, CAVT_OBJHANDLE, &tablesHandle));
caErrChk (Word_GetProperty (tablesHandle, NULL, Word_TableBorders, CAVT_OBJHANDLE, &bordersHandle);
caErrChk (Word_BordersItem (bordersHandle, NULL, -1, &borderHandle));
caErrChk (Word_SetProperty (borderHandle, NULL, Word_BorderLineStyle, CAVT_LONG, WordConst_wdLineStyleSingle));


The big idea here is to make sure you have the appropriate references and then use the Get/Set properties. The above code was created from that Word2000demo shipping example (notice how the AddTableToDoc function calls the FmtAllBorders toward the end and sends in the borders handle and some property and its value)

Hope this helps!

Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 2 of 3
(3,459 Views)
On Apr 7, 3:40 pm, Jonathan N <x...@no.email> wrote:
> Hi Mike,
>
> First off, I wanted to mention that the way LabWindows/CVI talks to Microsoft
> Word is done through ActiveX.&nbsp; All those Word examples you see with
> LabWindows/CVI are using an ActiveX generated wrapper (we created that wrapper
> which is either Word2000.fp or Word97.fp and shipped it with
> LabWindows/CVI).&nbsp; Now of course, we didn't include all the Microsoft Word
> methods and properties so if you find that you are missing something, you will
> need to generate your own wrapper via the ActiveX Controller Wizard.&nbsp;
> Also, as later versions of Microsoft Word come out, if you decide you would
> like to use the some of the newer methods and properties, you might need to
> regenerate the wrappers.&nbsp; For some additionally references, check out this <a href="message?board.id=180&amp;message.id=25828" target="_blank">post</a>
> in which I responded to another customer with some additionaly helpful links.
>
> To address your question, I am glad you found the section in the Word2000example
> which is formatting the tables (around line 673 in the AddTableToDoc
> function). Essentially what you need to do is get a handle to the table object
> and then to the borders object. At that point, you can use the Get/Set
> Properties to format the borders. For example, if you had a handle to the
> document (docHandle),
> then you could say
>
> caErrChk (Word_GetProperty (docHandle, NULL,
> Word_DocumentTables, CAVT_OBJHANDLE, &amp;tablesHandle));
> caErrChk (Word_GetProperty (tablesHandle, NULL, Word_TableBorders,
> CAVT_OBJHANDLE, &amp;bordersHandle);caErrChk (Word_BordersItem (bordersHandle, NULL, -1, &amp;borderHandle));caErrChk (Word_SetProperty (borderHandle, NULL, Word_BorderLineStyle,
> CAVT_LONG, WordConst_wdLineStyleSingle));
>
> The big idea here is to make sure you have the appropriate references and then
> use the Get/Set properties. The above code was created from that Word2000demo
> shipping example (notice how the AddTableToDoc function calls the FmtAllBorders
> toward the end and sends in the borders handle and some property and its value)
>
> Hope this helps!
>
> Best Regards,

Thanks for the help and the tips. It helped me to create a table
formatting function that I used in the WordRpt tables that I have
already generated and now it prints out the Word report complete with
formatted table borders and grids.

0 Kudos
Message 3 of 3
(3,444 Views)