好的,所以我有工作代码,但是添加文件的浏览器会在后台显示。这不会是那么糟糕,但是当这种情况发生时,很难快速达成目标。
我正在试图弄清楚如何让弹出式浏览器显示在所有内容之上,这样它就不会被埋没。它也非常慢,所以如果有更有效的方式,那也会很棒。这是我到目前为止所拥有的。
Option Explicit
Private Sub AttachmentFile()
Dim oLook As Object
Dim oMail As Object
Dim FD As Object
Dim vrtSelectedItem As Variant
Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.CreateItem(0)
Set FD = Excel.Application.FileDialog(3)
With oMail
FD.AllowMultiSelect = True
FD.Filters.Clear
FD.Filters.Add "All Files", "*.*"
FD.InitialFileName = "\\ad\dfs\Shared Data\"
If FD.Show = True Then
For Each vrtSelectedItem In FD.SelectedItems
.Attachments.Add vrtSelectedItem
Next
End If
.Display
End With
Set FD = Nothing
Set oMail = Nothing
Set oLook = Nothing
End Sub
答案 0 :(得分:0)
尽管Outlook中没有FileDialog
对象,但是您可以模拟使用ExecuteMso
按下按钮的情况。
要打开“ Outlook插入文件”对话框,请按AttachFile按钮:
Private Sub ExecuteMso_AttachFile()
Dim currItem As Object
On Error Resume Next
Set currItem = ActiveInspector.currentItem
On Error GoTo 0
If currItem Is Nothing Then Set currItem = CreateItem(olMailItem)
currItem.Display
' Hover over the icon that you would add as a button
' The IdMso to use in ExecuteMso is the last part of the text displayed.
ActiveInspector.CommandBars.ExecuteMso ("AttachFile")
End Sub