TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Coder on November 28, 2021, 11:14:56 AM
-
Hello guys,
I am trying to border Excel cells from B2 to B5 with one outside border but my code does not work for outside border.
(setq rang (vlax-get-property Sheet "Range" "B2:B5"))
(setq bord (vlax-get-property rang "Borders"))
(vlax-put-property bord "Color" (vlax-make-variant -1 3))
Anyone can help ?
Thank you.
-
maybe you need to specify what edge?
https://docs.microsoft.com/en-us/office/vba/api/excel.xlbordersindex
-
Yes I searched the same link you shared but unfortunately I don't know how to use it with the codes.
Can you please shed some light on it?
Thank you.
-
HI
TRY
(setq rang (vlax-get-property Sht "Range" "B2"))
(setq Cels (vlax-get-property Rang "Cells"))
(setq R1 1
C1 1)
(setq Cel (vlax-variant-value
(vlax-get-property Cels "Item"
;; row number :
(vlax-make-variant R1)
;; column number :
(vlax-make-variant C1))))
(setq Bords (vlax-get-property Cel "Borders"))
(setq cnt 0)
(vlax-for a Bords
(setq cnt (1+ cnt))
(vl-catch-all-apply (function (lambda()
(progn
(if (OR (= cnt 3)(= cnt 2)(= cnt 1));;(< cnt 4)
(progn
(vlax-put-property a "LineStyle"(vlax-make-variant 1 3))
(vlax-put-property a "Weight"(vlax-make-variant 4 3))
(vlax-put-property a "ColorIndex"(vlax-make-variant 1 5))
);progn
;; turn off the diagonal lines:
(vlax-put-property a "LineStyle" (vlax-make-variant -4142 3))
)
)
)
)
)
)
(setq rang (vlax-get-property Sht "Range" "B3"))
(setq Cels (vlax-get-property Rang "Cells"))
(setq R1 1
C1 1)
(setq Cel (vlax-variant-value
(vlax-get-property Cels "Item"
;; row number :
(vlax-make-variant R1)
;; column number :
(vlax-make-variant C1))))
(setq Bords (vlax-get-property Cel "Borders"))
(setq cnt 0)
(vlax-for a Bords
(setq cnt (1+ cnt))
(vl-catch-all-apply (function (lambda()
(progn
(if (OR (= cnt 2)(= cnt 1));;(< cnt 4)
(progn
(vlax-put-property a "LineStyle"(vlax-make-variant 1 3))
(vlax-put-property a "Weight"(vlax-make-variant 4 3))
(vlax-put-property a "ColorIndex"(vlax-make-variant 1 5))
);progn
;; turn off the diagonal lines:
(vlax-put-property a "LineStyle" (vlax-make-variant -4142 3))
)
)
)
)
)
)
(setq rang (vlax-get-property Sht "Range" "B4"))
(setq Cels (vlax-get-property Rang "Cells"))
(setq R1 1
C1 1)
(setq Cel (vlax-variant-value
(vlax-get-property Cels "Item"
;; row number :
(vlax-make-variant R1)
;; column number :
(vlax-make-variant C1))))
(setq Bords (vlax-get-property Cel "Borders"))
(setq cnt 0)
(vlax-for a Bords
(setq cnt (1+ cnt))
(vl-catch-all-apply (function (lambda()
(progn
(if (OR(= cnt 2)(= cnt 1));;(< cnt 4)
(progn
(vlax-put-property a "LineStyle"(vlax-make-variant 1 3))
(vlax-put-property a "Weight"(vlax-make-variant 4 3))
(vlax-put-property a "ColorIndex"(vlax-make-variant 1 5))
);progn
;; turn off the diagonal lines:
(vlax-put-property a "LineStyle" (vlax-make-variant -4142 3))
)
)
)
)
)
)
(setq rang (vlax-get-property Sht "Range" "B5"))
(setq Cels (vlax-get-property Rang "Cells"))
(setq R1 1
C1 1)
(setq Cel (vlax-variant-value
(vlax-get-property Cels "Item"
;; row number :
(vlax-make-variant R1)
;; column number :
(vlax-make-variant C1))))
(setq Bords (vlax-get-property Cel "Borders"))
(setq cnt 0)
(vlax-for a Bords
(setq cnt (1+ cnt))
(vl-catch-all-apply (function (lambda()
(progn
(if (OR (= cnt 4)(= cnt 2)(= cnt 1));;(< cnt 4)
(progn
(vlax-put-property a "LineStyle"(vlax-make-variant 1 3))
(vlax-put-property a "Weight"(vlax-make-variant 4 3))
(vlax-put-property a "ColorIndex"(vlax-make-variant 1 5))
);progn
;; turn off the diagonal lines:
(vlax-put-property a "LineStyle" (vlax-make-variant -4142 3))
)
)
)
)
)
)
-
Thank you hosneyalaa, it works great.