我想使用文件打开对话框来提取文件路径(或者如果更容易打开文件)
是否可以设置对话框,以便在双击文件名时不会打开文件?我要避免的是,如果用户双击文件名但该文件已经打开,则会出现进一步的警报。
OPEN
或者,或者,如果我进行设置以便在用户单击对话框的按钮或双击文件名时打开文件的只读版本,它会起作用- 这是一种更简单的方法吗?在这种情况下,我是否使用对话框的Execute
方法?
Private Function FindFilePath() As Boolean
Dim selectedMultiFiles As Boolean
Dim fd As FileDialog
Dim objfl As Variant
Set fd = Excel.Application.FileDialog(msoFileDialogOpen)
Dim myTxt As String
With fd
.Filters.Add "Excel Files", "*.xlsx;*.xlsm", 1
.AllowMultiSelect = False
.Title = "Choose the file with the target table"
.InitialView = msoFileDialogViewDetails
If .Show = -1 Then
myTxt = .SelectedItems.Item(1)
fFileName = myTxt
FindFilePath = True
Else
myTxt = "Nothing was selected"
FindFilePath = False
End If
On Error Resume Next End With
txBoxFilePath.Text = myTxt
End Function