LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Change text color of individual table cell using Word Report

I am using LabWindows/CVI version 8.0.1.

 

I started a Word application and opened an existing Word document using:

RESULT = WordRpt_ApplicationNew (VTRUE, &WORD_APP_HANDLE); // Open word application
RESULT = WordRpt_DocumentOpen (WORD_APP_HANDLE, "C:\\TEST_FILE.docx", &TEST_FILE_HANDLE); // Open report file

 

I then added a 2 row, 6 column table to my report file using (all text I put in the table is the default color of black):

RESULT = WordRpt_AddTable (TEST_FILE_HANDLE, 2, 6, &TABLE_HANDLE); // Add table

 

 

By adding a "SetTextAttribute" line before the table is created, I changed the color of all text in the table to blue

RESULT = WordRpt_SetTextAttribute (TEST_FILE_HANDLE, WR_ATTR_TEXT_COLOR, WRConst_Blue); // Set text to blue

RESULT = WordRpt_AddTable (TEST_FILE_HANDLE, 2, 6, &TABLE_HANDLE); // Add table

 

 

By creating the table one row at a time, I can have each row another color:

RESULT = WordRpt_SetTextAttribute (TEST_FILE_HANDLE, WR_ATTR_TEXT_COLOR, WRConst_Blue); // Set text to blue

RESULT = WordRpt_AddTable (TEST_FILE_HANDLE, 1, 6, &TABLE_HANDLE); // Add table

RESULT = WordRpt_SetTextAttribute (TEST_FILE_HANDLE, WR_ATTR_TEXT_COLOR, WRConst_Green); // Set text to green

RESULT = WordRpt_AddTable (TEST_FILE_HANDLE, 1, 6, &TABLE_HANDLE); // Add table

 

 

However, once set, I am not able change the color of a row nor am I able to have each column a different color text.

 

Does anyone know the coding to be able to build a table in a Word document where I can have individual cells in a table any color I want?

 

As another issue, I am also looking for coding to change the font of various table cells to bold.

0 Kudos
Message 1 of 1
(841 Views)