VBA Macro to run PowerShell Command
问题 I am trying to create a macro, that would be able to rename all files with ".docx" extension in a folder. The PowerShell command works when used directly, but when used through the VBA code, it's not executing. Sub test() Dim retval Dim pscmd pscmd = "PowerShell -ExecutionPolicy Bypass -Command ""Get-ChildItem -Path *.docx -Recurse | Rename-Item -NewName {$_.Name.Substring(0,7) + $_.Extension }""" retval = Shell(pscmd, vbNormalFocus) Debug.Print pscmd End Sub The script is executing without