TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: whdjr on May 23, 2005, 12:13:28 PM
-
Using Visual Lisp is there any way to determine if a particular Type Library is already loaded. I use this to load the Type Library for Word, but if it is already loaded I get an error that says the protected symbol is already used. Any ideas?
(http://www.theswamp.org/screens/whdjr/ScreenShot023.jpg)
(defun typeLib_word (/ sysdrv)
(setq sysdrv (getenv "systemdrive"))
(vl-remove
nil
(mapcar
'(lambda (x) (findfile (strcat sysdrv x)))
(list "\\Program Files\\Microsoft Office\\Office\\MSWord8.OLB"
"\\Program Files\\Microsoft Office\\Office\\MSWord9.OLB"
"\\Program Files\\Microsoft Office\\Office10\\MSWord.OLB"
"\\Program Files\\Microsoft Office\\Office11\\MSWord.OLB"
)
)
)
)
;;;
(defun load_typelib_word (/ tlb_file tlb_ver)
(and (setq tlb_file (car (typeLib_word)))
(vlax-import-type-library
:tlb-filename tlb_file
:methods-prefix "msw-"
:properties-prefix "msw-"
:constants-prefix "msw-"
)
)
)
-
2 options:
Turn off error warnings in the vlide
Check for a NON-NIL value for msw-Accept ...
Option 1:
Under the general options of the VLIDE, set error noitification to transparent
Option 2:
(if (not msw-Accept)
(load_typelib_word)
)
-
Thanks for the reply Keith, but is there a bigger issue than just vlide error warnings?
What I mean is that if you keep hitting no, it prompts with another message.
(http://www.theswamp.org/screens/whdjr/ScreenShot023.jpg)(http://www.theswamp.org/screens/whdjr/ScreenShot024.jpg)
(http://www.theswamp.org/screens/whdjr/ScreenShot025.jpg)(http://www.theswamp.org/screens/whdjr/ScreenShot026.jpg)
I have to shut down Autocad or bypass the portion of code that loads the type library before it will stop giving me error messages. That's the reason I was wondering if I could test to see if the type library could already be accessed from Vlisp, kinda like vl-catch-all-error-p determines if an argument is an error.
-
Thanks for the reply Keith, but is there a bigger issue than just vlide error warnings?
Actually that IS the issue ...
The VLIDE automatically prompts the user (using default settings) whenever any code attempts to set a value to a "protected" variable .. which ALL of the variable functions are when you load a type library ...
The VLIDE is doing EXACTLY what it should do... prompting you because your code is attempting to set a variable to a protected variable.
What I mean is that if you keep hitting no, it prompts with another message.
I have to shut down Autocad or bypass the portion of code that loads the type library before it will stop giving me error messages.
That is by design in the VLIDE ....
That's the reason I was wondering if I could test to see if the type library could already be accessed from Vlisp, kinda like vl-catch-all-error-p determines if an argument is an error.
This is not a lisp generated error, it is a VLIDE generated error. To intercept this error you would need to be able to control the VLIDE ... a much simpler solution is to set all of these errors to "transparent" in the VLIDE as I posted earlier, or to prevent them from ever happening, use the code I posted above ....
Essentially what happens is it checks to see if a single variable has already been set, if it has, then it is obvious that the type library has been loaded. If it is not, the it has not been loaded and you can load it without problem.
-
AAAHHHHHH!!!!!!
I see said the blind man. 8)
-
There is another point also you've to consider. Methods, properties or constants may have the same name. Vlisp isn't able to seperate those things. So you've to add an appropriate prefix (Excel sample):
(if (null excc-xl24HourClock)
(vlax-Import-Type-Library
:tlb-filename ExcTlb
:methods-prefix "excm-"
:properties-prefix "excp-"
:constants-prefix "excc-"
)
)
Cheers
-
Hi People,
is there a tutorial on how to get office stuff to work with vlisp? I'm very new to this type of programming. I'm a simple "draw a line" programmer. :oops:
thanks
Thomas
-
There is another point also you've to consider. Methods, properties or constants may have the same name. Vlisp isn't able to seperate those things. So you've to add an appropriate prefix (Excel sample): (if (null excc-xl24HourClock)
(vlax-Import-Type-Library
:tlb-filename ExcTlb
:methods-prefix "excm-"
:properties-prefix "excp-"
:constants-prefix "excc-"
)
)
Cheers
Thanks for clarifying that issue, however, you should note that in Will's original code, he does indeed add a prefix to designate the MicroSoftWord type library.
-
Thanks for clarifying that issue, however, you should note that in Will's original code, he does indeed add a prefix to designate the MicroSoftWord type library.
Im aware of that...
But methods, properties or constants probably can have the same names inside Word or whatever.
Cheers