Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 210

How do I get the return value of a Powershell script that is run in Excel VBA?

$
0
0

I am using Excel VBA to run a simple Powershell script that, when run in Powershell itself, returns one or two file names of some files within a given directory.

I can run this script from my VBA, but the return value is always some random integer. How do I get the script to return the file names that were returned through the Powershell script?

VBA to call script:

 Dim weekly As String weekly = Shell("Powershell ""<location of powershell script.ps1>""")

Script:

Get-ChildItem "<directory to search in>" | Where-Object {$_.Name -match "<regex to find file name>"}

If I have missed any details, please ask.


Viewing all articles
Browse latest Browse all 210

Trending Articles