【发布时间】:2021-06-10 18:42:00
【问题描述】:
我正在尝试为 VBA 函数 GetOpenfilename 设置默认目录。我之前设法让它工作,但在保存之前丢失了代码。
Sub Sample2()
Dim myFile As Variant
Dim i As Integer
Dim myApp As Excel.Application
Dim strCurDir As String
Set myApp = New Excel.Application
ChDrive ("H:\")
ChDir ("H:\99 - Temp")
'Open File to search
myFile = myApp.GetOpenFileName(MultiSelect:=True)
If myFile <> False Then
If IsArray(myFile) Then '<~~ If user selects multiple file
For i = LBound(myFile) To UBound(myFile)
Debug.Print myFile(i)
Next i
Else '<~~ If user selects single file
Debug.Print myFile
End If
Else
Exit Sub
End If
End Sub
我尝试了该代码的几种变体,但发现的帖子都非常旧。它将成为 Outlook 2016 中更大代码的一部分。
【问题讨论】:
-
这能回答你的问题吗? Setting up Directory for GetOpenFilename
-
@АлексейР 不幸的是没有。我找到的第一个链接之一,但谢谢
标签: excel vba outlook-2016 getopenfilename