我有下面的代碼,它工作正常,這一個(我用一個電話X,叫y宏),但是這一次不想上班前10個宏。Excel 2010中VBA錯誤。發送
Sub Send_Tips()
Application.DisplayAlerts = False
Dim Email_Subject, Email_Send_From, Email_Body As String, i As Integer
Dim Mail_Object, nameList As String, o As Variant
Email_Send_From = ""
For i = 1 To 1 'use cells 1 to 1 in column "A" where names are stored
If Sheets("Tips").Range("A1").Value <> "" Then
nameList = nameList & ";" & Sheets("Tips").Range("A" & i).Value
End If
Next
Set Mail_Object = CreateObject("Outlook.Application")
With Mail_Object.CreateItem(o)
.Subject = "Dealer Action Plans"
.To = nameList
.Body = "Please find attached the latest version of the Dealer Action Plans."
'Make a copy of the active sheet and save it to
'a temporary file
Worksheets("Tips").Activate
ActiveSheet.Copy
Set wb = ActiveWorkbook
Filename = "Tips.pdf"
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Worksheets("Tips").ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="c:\aaaWork\Tips.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
' ActiveWorkbook.SaveAs Filename:="C:\aaaWork\NC1.PDF", FileFormat:=17
.Attachments.Add "C:\aaaWork\Tips.PDF"
.send 'Will send straight away use .display to send manually
ActiveWorkbook.Close Saved = True
Kill "C:\aaaWork\Tips.PDF"
End With
Application.DisplayAlerts = True
End Sub
我得到當行 。發送「將直接送走使用。顯示發送手動 是跑了以下錯誤消息。 運行時錯誤'2147467259(80004005)': Outlook無法識別一個或多個名稱
表名稱提示確實存在,有什麼想法?
謝謝!
您的變量未正確聲明。這可能會幫助您調試。 –
如果將'.send'更改爲'.display',那麼錯誤(或類似的錯誤)是否會持續? –
此外,嘗試移動在其中創建臨時文件('工作表(「提示」)的代碼塊激活... OpenAfterPublish:= FALSE'爲*之前*'設置Mail_Object ...' –