• how to use vba variables in powershell script while running it from VBA?

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » how to use vba variables in powershell script while running it from VBA?

    Author
    Topic
    #1773886

    the Code in question is this and I am using this to Zip all files in a specified path using PowerShell and the path is given in a cell of a excel workbook.

    Code:
    Sub Button30_Click()
    Dim retval
    Dim a As String
    Dim b As String
    a = ThisWorkbook.Sheets(“INPUT TAB”).Range(“B79”).Value ‘getting the source path
    b = ThisWorkbook.Sheets(“INPUT TAB”).Range(“B79”).Value ‘getting the destination path
    retval = Shell(“Powershell “”Compress-Archive -Path ” & a & ” -CompressionLevel Optimal -DestinationPath ” & b)
    
    End Sub
    
    

    The actual powershell script is

    Code:
    Compress-Archive -LiteralPath C:TestingDemo -CompressionLevel Optimal -DestinationPath C:TestingDraft.Zip

    Please help me fix this so that the vba takes the path from a cell of excel and use it to run the PS script.

    Reply To: how to use vba variables in powershell script while running it from VBA?

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: