Can I pass a VBA variable into a called Powershell script?

后端 未结 1 1455
遇见更好的自我
遇见更好的自我 2021-01-27 07:15

I have a Powershell script to incorporate into an Excel VBA macro. Please reference this question: Powershell Regex: Replace only multiple spaces with tabs

This is the c

相关标签:
1条回答
  • 2021-01-27 07:42

    You just need to define parameters at the top of your script:

    param([string]$path)
    $content = [IO.File]::ReadAllText($path)
    # etc.
    

    In VBA, you need to pass the parameter:

    Shell("powershell.exe -ExecutionPolicy Unrestricted -File <pathname>\Convert_To_Tab_Delimited.ps1 -path """ & pathVariable & """", 1)
    
    0 讨论(0)
提交回复
热议问题