Hi @Sea-Haven
Thanks for sharing this - it seems close to the solution I need!
When I run this, as (upurl), with the spreadsheet open and active, it opens a blank instance of an Excel file, and asks me for a row number. I type 8 - that's the last row in my test spreadsheet.
I then get a "bad argument type: VLA-OBJECT nil" error.
I added (vl-load-com) at the beginning of the code, but not sure why it's opening another instance of Excel. Also, I found a typo- in the variable list for "bname" (it was spelled "banme").
Here is what I'm working with now:
(defun upurl ( / getcell2 myXL row rowmax x k ss ss2 bname ent obj atts att1 att2)
(vl-load-com)
;; Thanks to fixo ;;
(defun getcell2 (row column / )
(setq cells (vlax-get-property (vlax-get-property myXL "ActiveSheet") "Cells"))
(setq cell (vlax-get (vlax-variant-value (vlax-get-property cells "Item" row column)) 'value))
)
(or (setq myXL (vlax-get-object "Excel.Application"))
(setq myXL (vlax-get-or-create-object "excel.Application"))
)
(vla-put-visible myXL :vlax-true)
(vlax-put-property myXL 'ScreenUpdating :vlax-true)
(vlax-put-property myXL 'DisplayAlerts :vlax-true)
(setq row 2)
(setq rowmax (- (getint "\nEnter last row number ") 1))
(setq lst '())
(repeat rowmax
(setq c1 (getcell2 row 1)
c2 (getcell2 row 2)
c3 (getcell2 row 3)
)
(setq lst (cons (list c1 c2 c3) lst))
(setq row (1+ row))
)
(setq ss (ssget (list (cons 0 "INSERT")(cons 2 "**U*"))))
(if (= ss nil)(progn (Alert "you have not selected any DetailBubble blocks will exit ")(exit)))
(setq ss2 (ssadd))
(repeat (setq k (sslength ss))
(setq ent (ssname ss (setq k (1- k))))
(setq bname (vlax-get (vlax-ename->vla-object ent) 'effectivename))
(if (= bname "DetailBubble")
(setq ss2 (ssadd ent ss2))
)
)
(repeat (setq k (sslength ss2))
(setq obj (vlax-ename->vla-object (ssname ss2 (setq k (1- k)))))
(setq atts (vlax-invoke obj 'Getattributes))
(setq att1 (vlax-get (car atts) 'textstring))
(setq att2 (vlax-get (cadr atts) 'textstring))
(setq hyper_link (vla-item (vla-get-hyperlinks obj) 0))
(repeat (setq x (length lst))
(setq hyp (nth (setq x (1- x)) lst))
(setq hyp1 (car hyp) hyp2 (cadr hyp) hyp3 (caddr hyp) )
(if (and (= hyp1 att1)(= hyp2 att2))
(progn
(vla-put-url hyper_link hyp3)
(vla-put-urldescription hyper_link hyp3)
)
)
)
)
(princ)
)
But I'm still getting the error "bad argument type: VLA-OBJECT nil".
In VLIDE, I ran a "Check Selection" - and this is the return (not sure what I'm doing wrong):
[CHECKING TEXT <Untitled-0> loading... SELECTION]
.
; warning: local variable used as function: GETCELL2
; warning: local variable used as function: GETCELL2
; warning: local variable used as function: GETCELL2
; Check done.