Well...I got the code all translated, but the reference thing doesn't seem to want to work. I know how to set the reference, but when I try to do it I get a pop-up error message that says "Can't add a reference to the specified file.", for some reason. That reference is located at the following location (by default):
C:\Program Files\Autodesk\Inventor 2021\Bin\AddinNETFramework.AdWebServicesWrapper.dll
And to add it you would normally just (within the VBA Editor dialog) click on the 'Tools' tab, then click on 'References...', which brings up a References dialog. I don't think this item is usually listed, unless it goes by a different, hard to recognize name, so you would click the 'Browse...' button to browse to the specific dll file, and select it. But when I select this file and click the 'Open' button, I get that error. And without that reference being added, it won't recognize the 'CWebServicesManager' object.
I don't know if you still want to go this route or not since I couldn't set the reference needed, but here is the rest of the code (which really didn't need much translation at all):
Sub Main() '<<< I WOULD THIS FROM 'MAIN' TO SOMETHING ELSE >>>
Dim firstName As String
firstName = ""
Dim lastName As String
lastName = ""
If GetUserName(firstName, lastName) Then
Call MsgBox("Hello, " & firstName & " " & lastName, , "Personal message")
Else
Call MsgBox("Failed to get user info.", , "Fail")
End If
End Sub
Public Function GetUserName(ByRef firstName As String, ByRef lastName As String) As Boolean
On Error GoTo ErrorHndlr
Dim webServiceMgr As New CWebServicesManager()
If webServiceMgr.Initialize() Then
webServiceMgr.GetUserFirstName (firstName)
webServiceMgr.GetUserLastName (lastName)
If firstName = "" Or lastName = "" Then
firstName = ""
lastName = ""
GetUserName = False
Else
GetUserName = True
End If
Else
firstName = ""
lastName = ""
GetUserName = False
End If
GetUserName = True
Exit Function
ErrorHndlr:
firstName = ""
lastName = ""
GetUserName = False
End Function
In VBA macros, it's good practice to give your main Sub a unique name (will be the name of your macro), other than "Main", unlike in iLogic. You can try setting that reference on your PC, and see if maybe, for some reason, it will work for you, where it wouldn't work for me. You could also just have the macro run the iLogic rule, instead of putting all the code into the macro, if wanted/needed. Good luck.
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS
Wesley Crihfield

(Not an Autodesk Employee)