excel - 打开具有特定扩展名的文件
问题描述
使用 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
解决方案
推荐阅读
- jquery - 语法错误,无法识别的表达式:../#some_id
- c# - 将 2 个 JSON 字符串与一个公共密钥 c# 组合
- javascript - MongoDB:SyntaxError:属性列表后缺少}
- android - Android 可用高度限定符
- excel - 尝试找到最后填充的行后,我的宏不会停止运行
- clojure - 如何获取已在深度优先遍历中访问过的 Clojure 拉链部分?
- json - 使用 jq 从 base64 编码文本中迭代 JSON 数据
- email - 可定制的带有域名的电子邮件
- python - python文件读取循环问题
- android - Expo React Native - 模拟器调试菜单快捷方式突然停止在 Windows 上工作