Originally Posted by
cyware784241
I've done hours or research and I can't find the answer: is it possible to change the excel file in a datalink using AutoLISP statements?
In other words for a given datalink, I want to change the excel file. This is doable from the datalink window by editing the datalink.
thank you
Give this a whirl …
Code:
(setq datalinkDict (dictsearch (namedobjdict) "ACAD_DATALINK"))
(setq datalink (dictsearch (cdr (assoc -1 datalinkDict)) "TEST"))
(setq datapath (vl-string-subst "C:\\PATH\\CHANGE_TO_VALUE" "C:\\PATH\\ORIGINAL_VALUE" (cdr (assoc 301 datalink))))
(entmod (subst (cons 301 datapath) (assoc 301 datalink) datalink))
I believe placed datalinks will used assoc 301 and unused links will be assoc 302.
"TEST" is the name of the datalink, if all you are doing is updating the path all you should need to do is work out the logic and substitute "C:\\PATH\\CHANGE_TO_VALUE" "C:\\PATH\\ORIGINAL_VALUE" respectively.
Good luck.
Rob