使用PowerShell,我想使用*代替文件名来打开一个excel。下面的代码在第2行失败。寻找打开扩展名为* .xlsx
的文件$excel = New-Object -comobject Excel.Application
$FilePath_Excel = "C:\Users\Documents\FILES\*.xlsx"
$workbook2 = $excel.Workbooks.Open($FilePath_Excel)
$app = $excel.Application
$app.Run("Jan.xlsm!EOL")
$Excel.Workbooks.Close()
$excel.Quit()
出现以下错误
Sorry, we couldn't find C:\Users\Documents\FILES\*.xlsx. Is it possible it was moved, renamed or deleted? At C:\Users\Documents\FILES\Untitled1.ps1:7 char:1 + $workbook2 = $excel.Workbooks.Open($FilePath_Excel) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [], COMException + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException