From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX: How can I write values in a Word table with centered alignment?

Hello,

I have a big problem with generating my report in Word. If I write a value into a Word table cell the alignment always is left, but I want to switch the alignment to center. I tried a lot of things, but I´m not able to change the alignment in the table cells.

Can anybody help me?

Thomas
0 Kudos
Message 1 of 3
(3,182 Views)
allways a good source for informations about activex object properties is the MSDN from microsoft:
http://msdn.microsoft.com/library/default.asp
0 Kudos
Message 2 of 3
(3,168 Views)
Hello hamsti,

You can change the alignment of a paragraph in Word by using the SetProperty function in the Microsoft Word Object Library. In particular, if you insert the following code before adding data to the table, the table contents should be centered:

Word_GetProperty (currSelHandle, NULL, Word_SelectionParagraphFormat, CAVT_OBJHANDLE, &pgrphFmtHandle));
Word_SetProperty (pgrphFmtHandle, NULL, Word_ParagraphFmtAlignment, CAVT_LONG, WordConst_wdAlignParagraphCenter));

I tried this with the word200demo example. I would suggest opening the word2000demo shipping example located at ...\National Instruments\CVI71\samples\activex\word\word2000demo.cws and adding the above code to the AddTableToDoc callback function after the comment "Fill in the column titles".

You should see the desired results. Hope that helps.
0 Kudos
Message 3 of 3
(3,159 Views)