打开具有部分名称的文件
我正在尝试打开一个包含部分名称的文件。
当前名称为“GDE 投资组合特征 12.31.2021”。
我们的想法是打开它,无论日期如何(最后 10 个字符)。我的文件夹中应该只有一个文件具有这样的部分名称。
Workbooks.Open Filename:=ThisWorkbook.Path & "\Parametric GDE Portfolio Characteristics*.xlsx"
它找不到该文件。如果我使用文件的完整名称,它就可以工作。
I am trying to open a file with partial name.
The current name is "GDE Portfolio Characteristics 12.31.2021".
The idea is to open it, no matter the date (last 10 characters). I should only have one file in the folder with such a partial name.
Workbooks.Open Filename:=ThisWorkbook.Path & "\Parametric GDE Portfolio Characteristics*.xlsx"
It does not find the file. It works if I use the entire name of the file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无法在 Open 语句中使用通配符。但是,您可以使用
Dir
- 命令获取真实文件名,因为它允许通配符:There is no way to use a wildcard in the Open-statement. However, you can use the
Dir
-command to get the real file name as it allows wildcards:这是一种更通用的方法:
Here is a more generic approach: