(vl-cmdf "vbastmt" "acadapplication.documents.open \"c:/path/mydwg.dwg\",TRUE")
This will open the dwg file (if it exists) read only.
... I am wanting to do this on a list of dwgs... I get syntax error... but I think I am close
(foreach dwg (list "C:/Path/dwg1" "C:/Path/dwg2" "C:/Path/dwg3")
(vl-cmdf "vbastmt" (strcat "acadapplication.documents.open " (chr 92)(chr 34) dwg (chr 92)(chr 34) ",TRUE"))
)
Do you have to use VBA?
I dont have VBA in this laptop, but if your goal is to open a dwg list readonly, perhaps something like this
(foreach dwg (list "C:/Path/dwg1" "C:/Path/dwg2" "C:/Path/dwg3") (vla-open (vla-get-documents (vlax-get-acad-object)) (strcat "\"" dwg "\"") :vlax-true) )
HTH
Henrique
This might work... I just happened to think though... I wonder if the lisp would halt in it's track when the second drawing opens... since vocus would leave the drawing where it was launched.
The only other thing if a script would do this... I've ran scripts on multiple dwg files... they open fine even in SDI = 0
"I wonder if the lisp would halt in it's track when the second drawing opens... since vocus would leave the drawing where it was launched."
Using "vla-open" without "activate" the dwg, the lisp will open readonly all the dwg's in the list and return to the original dwg.
Using the "vbastmt", and you only need a to use a (chr 34) not a (chr 92) (chr 34)
i.e.
(setq dwg "C:/Path/dwg1")
(vl-cmdf "vbastmt" (strcat "acadapplication.documents.open " (chr 34) dwg (chr 34) ",TRUE"))
If my memory don't trick me, using "vbastmt" with a dwg list, would halt at the first opened dwg... I can't test it...
"The only other thing if a script would do this..."
The only way I know to open dwg's readonly from a script file, isn't a clean way, so I think it's better not to post it...
Henrique