我开发了一个简短的宏,允许我的365用户将电子邮件保存到项目文件夹。 我有2个用户仍然在2010年,我无法弄清楚为什么代码不起作用。 我以为这是一个参考或同样容易的东西,但没有运气。 这是代码,如果有人有一个想法
- Sub SaveACopy() 'ByVal Item As Object) 'Item As Object
- Const olMsg As Long = 3
- Dim m As MailItem
- Dim strPath As String
- Set m = GetCurrentItem
- If TypeName(m) "MailItem" Then Exit Sub
- Dim xlApp As Object
- Set xlApp = CreateObject("Excel.Application")
- xlApp.Visible = False
- Dim fd As Office.FileDialog
- Set fd = xlApp.Application.FileDialog(msoFileDialogFolderPicker)
- Dim selectedItem As Variant
- If fd.Show = -1 Then
- For Each selectedItem In fd.SelectedItems
- Debug.Print selectedItem
- strPath = selectedItem
- Next
- End If
- Set fd = Nothing
- xlApp.Quit
- Set xlApp = Nothing
- Dim strSubject As String
- strSubject = m.Subject
- strSubject = Replace(strSubject, ":", "")
- 'strPath = """" & strPath
- strPath = strPath & "" & strSubject
- strPath = strPath & " " & Format(Now(), "ddmmmyyyy-hhNNss") '"yyyy-mm-dd-hhnnss" YYYY-mm-dd
- strPath = strPath & ".msg"
- strPath = strPath '& """"
- m.SaveAs strPath, olMsg
- m.Close olDiscard
- End Sub
- 'Set objItem = objApp.ActiveExplorer.Selection.Item(1)
- Function GetCurrentItem() As Object
- Dim objApp As Outlook.Application
- Set objApp = Application
- On Error Resume Next
- Select Case TypeName(objApp.ActiveWindow)
- Case "Explorer"
- Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
- Case "Inspector"
- Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
- End Select
- Set objApp = Nothing
- End Function
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |