0

I created a VBA userform (named UserParam) to save my Solidworks files. The userform contains among others two options: save as .STEP or as .XT. I used the following codes, but only the .STEP extension works and the .XT does not. My Userform events:

Private Sub CmdBtnUserParam_Click()
    'TYPE OF EXTENSION
    Dim OptionExtension As String
    
    If optbtnStep.Value = True Then
        OptionExtension = ".STEP"
    ElseIf optbtnXT.Value = True Then
        OptionExtension = ".XT"
    Else
        MsgBox "Please select an extension type"
    End If
 'Call the UserInput subroutine to enter the variables
    Call UserInput(OptionExtension)
End Sub

My Sub main (partially):

Public Sub UserInput(OptionExtension As String)

    Dim ExtInit , ExtOption Filename XTFolder as string
    'New pathname
    ExtInit = ".SLDPRT" 'Old extension
    ExtOption = OptionExtension
    Filename = "C:\Users\Folder\XT\Partname"
    XTFolder = "XT\"

     Set Part = swApp.OpenDoc6(Filename + ExtInit, 1, 0, "", longstatus, longwarnings)
    longstatus = Part.SaveAs3(Filename + XTFolder + ExtOption, 0, 2)
End Sub

So "ExtOption" should be either ".STEP" or ".XT", based on the preferences of the user. Can someone give me some advice on how to achieve this goal?

Thank you in advance. If anything is unclear, please let me know.

2
  • 1
    Is the file extension ".XT" correct or do you mean ".X_T"? Commented Aug 5, 2024 at 12:18
  • @Shrotter thank you. Such a foolish mistake of me. I changed it and it works perfectly. Commented Aug 5, 2024 at 13:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.