That's basically my question. Doing googling didn't return anything that I am looking for, but basically I am running SOLIDWORKS from Excel and for that I need "sldworks 2016 Type Library" and "SOLDIWORKS 2016 Constant Type Library" to be enabled. Of course you'd say to do it manually, BUT my program is being run both, by people with and without Solidworks installed and if a user doesn't have SOLDIWORKS on their PC - the entire thing won't even run. So I am looking to enable and disable those two type libraries upon necessity in the code.
Could, someone, please help me?
P.S. I am not looking for any workarounds etc.
Is this what you are trying? The below code will first try to bind with an open instance of
SOLIDWORKS. If it is not open, then it will try to create a new instance. Obviously ifSOLIDWORKSis not installed then theCreateObjectwill fail but the code will not crash because ofOn Error Resume Next. Finally check ifobjSolidis not nothing. This is late binding and you do not have to set any references.EDIT
You cannot say Solidworks is not properly documented without putting in the right efforts to search. It took me less than 30 seconds to find this SOLIDWORKS Example of Late Binding. Of course their code will fail if the user doesn't have
SOLIDWORKSand that is because they have not done proper error handling. My answer above does that for you.Their website has all the information that you need. You just need to put in the right efforts to search. As I mentioned in the chat below, when you convert the code into late binding, you will have to search for the value of those
constants. No one will give them to you in a platter. :) You can either search Google withswDocPART Constant valueor as @FunThomas pointed out, type?swDocPARTin Immediate Window to get the value when the reference toSOLIDWORKShas been established.