Jul 17, 2002 #1 krindler Programmer Jul 16, 2002 39 US Hello Again... I have one more question regarding OLE2. Does anyone have an example of adding borders to a specific cell in Excel, using OLE2? Your help is much appreciated. Thanks!! Kelly
Hello Again... I have one more question regarding OLE2. Does anyone have an example of adding borders to a specific cell in Excel, using OLE2? Your help is much appreciated. Thanks!! Kelly
Jul 18, 2002 Thread starter #2 krindler Programmer Jul 16, 2002 39 US Okay, I have figured out how to get a double line border around the entire cell, using the following code: args := OLE2.CREATE_ARGLIST; OLE2.ADD_ARG ( args, 16 ); OLE2.ADD_ARG ( args, 4 ); cell := OLE2.GET_OBJ_PROPERTY ( worksheet, 'Cells', args ); OLE2.DESTROY_ARGLIST ( args ); OLE2.SET_PROPERTY ( cell, 'ColumnWidth', 14.57 ); font := OLE2.GET_OBJ_PROPERTY ( cell, 'font' ); OLE2.SET_PROPERTY ( font, 'bold', true ); border := OLE2.GET_OBJ_PROPERTY ( cell, 'Borders' ); OLE2.SET_PROPERTY ( border, 'LineStyle', -4119 ); OLE2.RELEASE_OBJ ( cell ); I would now like to only print this double line on the Bottom Edge of the Cell. Does anyone have any idea how to do that? Thanks!! Kelly Upvote 0 Downvote
Okay, I have figured out how to get a double line border around the entire cell, using the following code: args := OLE2.CREATE_ARGLIST; OLE2.ADD_ARG ( args, 16 ); OLE2.ADD_ARG ( args, 4 ); cell := OLE2.GET_OBJ_PROPERTY ( worksheet, 'Cells', args ); OLE2.DESTROY_ARGLIST ( args ); OLE2.SET_PROPERTY ( cell, 'ColumnWidth', 14.57 ); font := OLE2.GET_OBJ_PROPERTY ( cell, 'font' ); OLE2.SET_PROPERTY ( font, 'bold', true ); border := OLE2.GET_OBJ_PROPERTY ( cell, 'Borders' ); OLE2.SET_PROPERTY ( border, 'LineStyle', -4119 ); OLE2.RELEASE_OBJ ( cell ); I would now like to only print this double line on the Bottom Edge of the Cell. Does anyone have any idea how to do that? Thanks!! Kelly
Jul 18, 2002 2 #3 sfvb Programmer Nov 25, 2001 399 US Here are some examples. The contstants I use are in blue ---- LineStyle constants default is xlContinuous xlContinuous constant number(5):= 1; xlDash constant number(5):= -4115; xlDashDot constant number(5):= 4; xlDashDotDot constant number(5):= 5; xlDot constant number(5):= -4118; xlDouble constant number(5):= -4119; xlLIneStyleNone constant number(5):= -4142; xlSlantDashDot constant number(5):= 13; ---- Weight constants default is xlThin xlHairline constant number(5):= 1; xlThin constant number(5):= 2; xlMedium constant number(5):= -4138; xlThick constant number(5):= 4; ---- Borders Index constants default is xlThin xlDiagonalDown constant number(5):= 5; xlDiagonalUp constant number(5):= 6; xlEdgeBottom constant number(5):= 9; xlEdgeLeft constant number(5):= 7; xlEdgeRight constant number(5):= 10; xlEdgeTop constant number(5):= 8; xlInsideHorizontal constant number(5):= 12; xlInsideVertical constant number(5):= 11; ----------------------------------- ----Set Border part for cell E8---- ----------------------------------- args := OLE2.CREATE_ARGLIST; OLE2.ADD_ARG(args, '8'); OLE2.ADD_ARG(args, 'E'); cell := OLE2.GET_OBJ_PROPERTY(worksheet, 'Cells', args); OLE2.DESTROY_ARGLIST(args); args:= ole2.create_arglist; ole2.add_arg(args, xlDiagonalDown); borders := OLE2.GET_OBJ_PROPERTY(cell, 'Borders', args); OLE2.DESTROY_ARGLIST(args); OLE2.SET_PROPERTY(borders, 'LineStyle', xlDash); OLE2.SET_PROPERTY(borders, 'Weight', xlThin); OLE2.SET_PROPERTY(borders, 'ColorIndex', 4); OLE2.RELEASE_OBJ(borders); args:= ole2.create_arglist; ole2.add_arg(args, xlEdgeLeft); borders := OLE2.GET_OBJ_PROPERTY(cell, 'Borders', args); OLE2.DESTROY_ARGLIST(args); OLE2.SET_PROPERTY(borders, 'LineStyle', xlDashDotDot); OLE2.SET_PROPERTY(borders, 'Weight', xlThin); OLE2.SET_PROPERTY(borders, 'ColorIndex', 3); OLE2.RELEASE_OBJ(borders); args:= ole2.create_arglist; ole2.add_arg(args, xlEdgeBottom); borders := OLE2.GET_OBJ_PROPERTY(cell, 'Borders', args); OLE2.DESTROY_ARGLIST(args); OLE2.SET_PROPERTY(borders, 'LineStyle', xlDouble); OLE2.SET_PROPERTY(borders, 'Weight', xlThin); OLE2.SET_PROPERTY(borders, 'ColorIndex', 5); OLE2.RELEASE_OBJ(borders); OLE2.RELEASE_OBJ(cell); ------------------------------------ ----Set Border whole for cell C8---- ------------------------------------ args := OLE2.CREATE_ARGLIST; OLE2.ADD_ARG(args, '8'); OLE2.ADD_ARG(args, 'C'); cell := OLE2.GET_OBJ_PROPERTY(worksheet, 'Cells', args); OLE2.DESTROY_ARGLIST(args); args:= ole2.create_arglist; ole2.add_arg(args, xlContinuous); ole2.add_arg(args, xlThick); ole2.add_arg(args, 5); OLE2.INVOKE(cell, 'BorderAround', args); OLE2.RELEASE_OBJ(cell); Upvote 0 Downvote
Here are some examples. The contstants I use are in blue ---- LineStyle constants default is xlContinuous xlContinuous constant number(5):= 1; xlDash constant number(5):= -4115; xlDashDot constant number(5):= 4; xlDashDotDot constant number(5):= 5; xlDot constant number(5):= -4118; xlDouble constant number(5):= -4119; xlLIneStyleNone constant number(5):= -4142; xlSlantDashDot constant number(5):= 13; ---- Weight constants default is xlThin xlHairline constant number(5):= 1; xlThin constant number(5):= 2; xlMedium constant number(5):= -4138; xlThick constant number(5):= 4; ---- Borders Index constants default is xlThin xlDiagonalDown constant number(5):= 5; xlDiagonalUp constant number(5):= 6; xlEdgeBottom constant number(5):= 9; xlEdgeLeft constant number(5):= 7; xlEdgeRight constant number(5):= 10; xlEdgeTop constant number(5):= 8; xlInsideHorizontal constant number(5):= 12; xlInsideVertical constant number(5):= 11; ----------------------------------- ----Set Border part for cell E8---- ----------------------------------- args := OLE2.CREATE_ARGLIST; OLE2.ADD_ARG(args, '8'); OLE2.ADD_ARG(args, 'E'); cell := OLE2.GET_OBJ_PROPERTY(worksheet, 'Cells', args); OLE2.DESTROY_ARGLIST(args); args:= ole2.create_arglist; ole2.add_arg(args, xlDiagonalDown); borders := OLE2.GET_OBJ_PROPERTY(cell, 'Borders', args); OLE2.DESTROY_ARGLIST(args); OLE2.SET_PROPERTY(borders, 'LineStyle', xlDash); OLE2.SET_PROPERTY(borders, 'Weight', xlThin); OLE2.SET_PROPERTY(borders, 'ColorIndex', 4); OLE2.RELEASE_OBJ(borders); args:= ole2.create_arglist; ole2.add_arg(args, xlEdgeLeft); borders := OLE2.GET_OBJ_PROPERTY(cell, 'Borders', args); OLE2.DESTROY_ARGLIST(args); OLE2.SET_PROPERTY(borders, 'LineStyle', xlDashDotDot); OLE2.SET_PROPERTY(borders, 'Weight', xlThin); OLE2.SET_PROPERTY(borders, 'ColorIndex', 3); OLE2.RELEASE_OBJ(borders); args:= ole2.create_arglist; ole2.add_arg(args, xlEdgeBottom); borders := OLE2.GET_OBJ_PROPERTY(cell, 'Borders', args); OLE2.DESTROY_ARGLIST(args); OLE2.SET_PROPERTY(borders, 'LineStyle', xlDouble); OLE2.SET_PROPERTY(borders, 'Weight', xlThin); OLE2.SET_PROPERTY(borders, 'ColorIndex', 5); OLE2.RELEASE_OBJ(borders); OLE2.RELEASE_OBJ(cell); ------------------------------------ ----Set Border whole for cell C8---- ------------------------------------ args := OLE2.CREATE_ARGLIST; OLE2.ADD_ARG(args, '8'); OLE2.ADD_ARG(args, 'C'); cell := OLE2.GET_OBJ_PROPERTY(worksheet, 'Cells', args); OLE2.DESTROY_ARGLIST(args); args:= ole2.create_arglist; ole2.add_arg(args, xlContinuous); ole2.add_arg(args, xlThick); ole2.add_arg(args, 5); OLE2.INVOKE(cell, 'BorderAround', args); OLE2.RELEASE_OBJ(cell);