0

I am trying to make a tool in VBA excel. I created a userform with a textbox and some checkboxes. Underneath this checkbox i have 3 buttons. Each button has to run a powershell script. The powershell script is as following ('value-button', 'value from textbox', 'value from chosen option in checkbox') and if more than one chosen option the value must end with a ',' in the powershell script. Like this for example if i choose 3 options (XXX-0037,XXX-0037,XXX-0077)

I am getting now the above error with this code: Invalid procedure call or argument

I tried this code:

Private Sub togglebutton1_Click()
    Dim value As String
    Dim choice As String
    value = TextBox1.Text
    If CheckBox1.value = True Then
        choice = "LA1-037"
    ElseIf CheckBox2.value = True Then
        choice = "LA1-077"
    End If
    Dim command As String
    command = "Start-ExamSession -value " & value & " -choice " & choice
    Call Shell("powershell.exe -command " & command, vbHide)
End Sub

Can anyone help me out with this?

BigBen
  • 46,229
  • 7
  • 24
  • 40
MoBo87
  • 1
  • The error seems to be on this line: Call Shell("powershell.exe -command " & command, vbHide) – MoBo87 Jan 10 '23 at 17:32

0 Answers0