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 code in question Convert_To_Tab_Delimited.ps1:
gc 'foo.txt'| % { $_ -replace ' +',"`t" } | set-content "<my path>\temp.txt"
I need to get 'foo.txt' to be a VBA variable that I pass to it. Basically a path string that is obtained from a select file dialog in VBA. The Powershell file will be called by this statement:
Shell(“powershell.exe -ExecutionPolicy Unrestricted <pathname>\Convert_To_Tab_Delimited.ps1″, 1)
Is there a way to pass a string variable as an argument to the called Powershell script? Any assistance with this would be greatly appreciated!