【发布时间】:2016-02-13 18:52:52
【问题描述】:
Sub Main()
Dim FSO As New FileSystemObject
Dim Fl As File
Dim Folder As Folder
Dim F_Name, F_Path As String
F_Path = ThisWorkbook.Path & "\"
Set Folder = FSO.GetFolder(F_Path)
F_Name = "CI*.*"
For Each Fl In Folder.Files
If Fl.Name = F_Name Then
GoTo Report
End If
Next
Report:
Workbooks.Open Filename:=F_Path & F_Name
我想打开一个相同位置的 excel 文件,但我只知道文件名的一部分,所以请协助我如何打开文件名。谢谢!
【问题讨论】:
-
您必须使用 Dir 函数通过通配符打开文件。 techonthenet.com/excel/formulas/dir.php
-
尝试将
If Fl.Name = F_Name Then改为If Fl.Name Like F_Name Then -
这个答案将帮助您完成它stackoverflow.com/questions/19527415/…
-
但是在搜索之后如何打开那个特定的文件
-
在这一行将
F_Name更改为Fl.NameWorkbooks.Open ....