-1
我有一個工作簿,我正嘗試使用宏進行電子郵件發送。這樣收件人也可以使用工作簿附帶的宏。這將使我的公司更容易辦公。我試圖將保存的文件名設置爲.xlsm,但這會導致錯誤。使用宏和所有電子郵件發送工作簿
這是我的代碼(這是從源適應在線)
Sub MailGo()
'Variable declaration
Dim oApp As Object, _
oMail As Object, _
WB As Workbook, _
FileName As String, MailSub As String, MailTxt As String
'Turns off screen updating
Application.ScreenUpdating = False
'Makes a copy of the active sheet and save it to
'a temporary file
ActiveSheet.Copy
Set WB = ActiveWorkbook
FileName = "Text.xls"
On Error Resume Next
Kill "C:\" & FileName
On Error GoTo 0
WB.SaveAs FileName:="C:\Users\Public\Documents" & FileName
'Creates and shows the outlook mail item
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
With oMail
.To = "[email protected]"
.Cc = ""
.Bcc = ""
.Subject = "LotInput"
.Body = "LotInput"
.Attachments.Add WB.FullName
.Display
.send
End With
'Deletes the temporary file
WB.ChangeFileAccess Mode:=xlReadOnly
Kill WB.FullName
WB.Close SaveChanges:=False
'Restores screen updating and release Outlook
Application.ScreenUpdating = True
Set oMail = Nothing
Set oApp = Nothing
End Sub
在沒有來自您的sysAdmin的幫助下,您可能無法獲得電子郵件安全設置,但禁用這些安全功能是不可取的。當然,有一個共同的文件共享,你可以保存它,然後在文件的電子郵件中包含一個鏈接,以便他們可以將'xlsm'下拉到本地機器。 – GibralterTop
什麼是錯誤,以及導致它的是什麼指令? –