Well I dont' know how much specific I can be, but I'll try. You just have a
bug eg. erroneous line of code in your code and you have to fix it, there is
no more sophisticated way than debugging. In your addin class module, find
the function named ConnectToSW. Select the first statement eg. row of code
in the function and hit F9 to toggle a breakpoint on that line. Then hit F5
to start the add-in. Start SolidWorks and the code execution breaks on the
breakpoint, and after that you can run the code row by row by hitting F8.
Select View -> Locals to see the current values of your local variables. Try
to find the row which causes an error, and then fix the code. This process
is called de-bugging. You can also right-click the code and select Toggle ->
Break on all errors, so you don't have to put a breakpoint but instead the
code breaks automatically on a row which causes an error.
Hope this helps!