该项目的目的是:
通过快速访问或主要工具栏中的按钮调用宏。
问题:
当出现“浏览”窗口时,它会在outlook / hidden后面显示,除非在Outlook打开后的某个时间在编辑器中查看了宏代码;每个修复程序要么显示整个Word程序,要么似乎没有效果。
当您在“浏览”中选择文件然后单击“确定”时,将打开第二个“浏览”窗口,您必须再次选择一个文件,然后单击“打开”;然后,第二个文件将附加到电子邮件中。< - 已修复
系统细节(尽管并非所有都很重要)
Windows 7 64bit
Office Professional 2010
守则
Sub New_Orders_Email()
Dim NewMail As Outlook.MailItem
Dim otherObject As Word.Application
Dim fd As Office.FileDialog
Dim fileaddress As String
Dim filename As String
On Error GoTo Final
'Set template to use
Set NewMail = Application.CreateItemFromTemplate("P:\Office Templates\Orders SCI - 1617.oft")
'Set to use Word for Attach File Dialog
Set otherObject = New Word.Application
otherObject.Visible = False
Set fd = otherObject.Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
.InitialFileName = "R:\Science\Technician Documents\Budgets & Orders\2016 - 2017\Orders\"
.Show
End With
fd.Show
fileaddress = fd.SelectedItems(1)
'Aquire File Name in correct form for Subject Line
Dim MidStart As Long
MidStart = InStrRev(fileaddress, "\") + 16
Dim MidEnd As Long
MidEnd = InStrRev(fileaddress, ".")
filename = Mid(fileaddress, MidStart, MidEnd - MidStart)
'Load template, attach single file and apply correct Subject
NewMail.Display
NewMail.Attachments.Add (fileaddress)
NewMail.Subject = "Order No: " + filename
otherObject.Quit
Set otherObject = Nothing
Final:
End Sub
答案 0 :(得分:0)
您的文件对话框可能未显示,因为该行" otherObject.Visible = False"
如果您删除其中一个" fd.Show",则数字(2)可能会被解决。看起来你叫它两次......