Stop loading of Add-In on Add-in Load

Programming and macros
lukekfrost
Posts: 1
Joined: Thu Aug 24, 2023 4:06 am
Answers: 0

Stop loading of Add-In on Add-in Load

Unread post by lukekfrost »

Good Morning All,

I am in the final stages of creating an Add-In for internal use which requires users to login to the Add-In prior to using it. I have got the following code which I have put in the ConnectToSW Function.

'Check if initial setup has been run
If My.Computer.Registry.GetValue("HKEY_CURRENT_USER\SOFTWARE\Snowman Design\CMD_SW_Add-in", "initial", Nothing) = 1 Then
Dim OpeningForm As New frmInitialSetup
If OpeningForm.ShowDialog = Windows.Forms.DialogResult.OK Then
ConnectToSW = True
Else
'Stop the loading of the Add-In and unload it
MsgBox("You are required to login to this Add-In for it to work")
End If
Else
Dim OpeningForm As New FrmLogin
If OpeningForm.ShowDialog = Windows.Forms.DialogResult.OK Then
ConnectToSW = True
End If
End If

The end result that i am trying to achieve is that when the add-in is loaded, either automatically on SOLIDWORKS startup or just a one off instance when SOLIDWORKS is running, a login dialogue box is displayed and if the dialogresult is anything other than ok then the add-in is unloaded.

I have tried things like calling the DissconnectFromSW or RemoveTaskPane Functions, however i am getting no joys. Hopefully someone can help with this one.

Just for clarification i am using Visual Studio 2019 and vb.net to write the add-in and not vba.

As always thank you in advance for your help.

Luke
User avatar
bnemec
Posts: 1848
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2431
x 1330

Re: Stop loading of Add-In on Add-in Load

Unread post by bnemec »

Post Reply