Author Topic: Border Excel cells with outside style  (Read 1069 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Border Excel cells with outside style
« 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.

Code: [Select]
        (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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: Border Excel cells with outside style
« Reply #1 on: November 28, 2021, 05:03:16 PM »

Coder

  • Swamp Rat
  • Posts: 827
Re: Border Excel cells with outside style
« Reply #2 on: November 29, 2021, 05:14:01 AM »
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.

HOSNEYALAA

  • Newt
  • Posts: 103
Re: Border Excel cells with outside style
« Reply #3 on: November 29, 2021, 06:48:46 AM »
HI
TRY

Code: [Select]



 (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))
      )
    )
  )
)
    )
  )














Coder

  • Swamp Rat
  • Posts: 827
Re: Border Excel cells with outside style
« Reply #4 on: November 29, 2021, 08:35:17 AM »
Thank you hosneyalaa, it works great.