【发布时间】:2019-11-06 12:59:36
【问题描述】:
我开发了一个 Outlook 宏,让用户可以选择并打开 Excel 文件。
文件对话框在后台打开。在用户看来,Outlook 应用程序似乎被卡住了,而它只是在等待用户在所有其他窗口后面的 Filepicker 对话框中选择一个文件。
Dim SigFolder2 As String
Dim fd As Office.FileDialog
Dim selectedItem As Variant
Dim ExcelFileName As String
Dim FileName As String
Dim objExcel As New Excel.Application
Dim exWb As Excel.Workbook
'Suggested Folder--Downloads
SigFolder2 = "C:\Users\" & Environ("UserName") & "\Downloads\"
'Dialog Settings
Set fd = objExcel.FileDialog(msoFileDialogFilePicker)
With fd
.Filters.Clear
.InitialFileName = SigFolder2
.AllowMultiSelect = False
.Title = "Select Signature File"
End With
'Getting the file
If fd.Show = -1 Then
For Each selectedItem In fd.SelectedItems
SigFolder = selectedItem
Next
Else
Exit Sub
End If
ExcelFileName = SigFolder
FileName = Left(fso.GetFileName(ExcelFileName), InStr(fso.GetFileName(ExcelFileName), ".") - 1)
Debug.Print ExcelFileName 'file Path with filename
有什么办法可以改正吗?
【问题讨论】:
标签: excel vba outlook filepicker