LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing border appearance in Excel from CVI

Hi.
This is an old problem and I stil don't have a solution.
A tried to control the border of a range of cells in Excel from CVI.

I used this function:

status = Excel_RangeBorderAround (ExcelRangeHandle,NULL,CA_DEFAULT_VAL,ExcelConst_xlThick,ExcelConst_xlColorIndexAutomatic,CA_DEFAULT_VAL,
&Value);
and this works, but I just need to change the top part of the border cell.

I used this function:

status = Excel_RangeAutoFormat (ExcelRangeHandle,NULL,ExcelConst_xlRangeAutoFormatAccounting3,CA_DEFAULT_VAL,CA_DEFAULT_VAL,CA_DEFAULT_VAL, CA_DEFAULT_VAL,CA_DEFAULT_VAL,CA_DEFAULT_VAL,&Value);

and it works.This function change the top part of the border of a range cells, but it changes the font too, and I don't want t
his.

Thanks.
0 Kudos
Message 1 of 4
(3,546 Views)
Hi,

If you can't get the results that you need with those functions, you could write a very simple macro that chages the border on the currently selected cells;
Then you can call this macro form CVI to get the cells formated.

I am attaching an example on mcros for your reference. It is unde review righ now, but should be on the web soon.

I hope this helps.

Regards,

Juan Carlos
N.I.
0 Kudos
Message 2 of 4
(3,546 Views)
Hi.
I found the answer of my question so I'll put it on the forum hoping that it helps others.

First of all I got the range of my cells:

error = CA_VariantSetCString (&MyCellRangeV, EXCEL_ARRAY_OF_CELLS);
error = Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, &ExcelRangeHandle);

Second, I got the borders of my range cells into a handle:

error = Excel_GetProperty (ExcelRangeHandle, &ErrorInfo,Excel_RangeBorders, CAVT_OBJHANDLE,
&ExcelBorderHandle);

Now I get the bottom edge of my range cells into a handle:

status = Excel_BordersItem (ExcelBorderHandle, NULL,
ExcelConst_xlEdgeBottom,
&ExcelBorderHandleX);

Now, I change the line style of the bottom edge of my range cells:

error = Excel_SetProperty (ExcelBorder
HandleX, &ErrorInfo,Excel_BorderLineStyle, CAVT_VARIANT,
CA_VariantLong (1));

Finaly, I have changed the border weight of the bottom edge, of my range cells:

error = Excel_SetProperty (ExcelBorderHandleX, &ErrorInfo,Excel_BorderWeight, CAVT_VARIANT,CA_VariantLong (3));

Hope this helps.
0 Kudos
Message 3 of 4
(3,546 Views)
I'm glad you got that up a running, it's definatelly not very intuitive. The Excel API can get complicated.

Good luck.

Juan Carlos
0 Kudos
Message 4 of 4
(3,546 Views)