【发布时间】:2018-08-10 15:52:49
【问题描述】:
以下是我发送邮件的代码:
Sub SendRequestForApprovalMail()
Application.ScreenUpdating = False
Application.StatusBar = "Step 1/2 - Retrieving your pending approvals from SharePoint..."
Range("T_myPendingApprovals[#All]").ListObject.Refresh
'new in v.5.0 - date format is changed as for some users the date format looks strange
Union(Range("T_myPendingApprovals[Start]"), Range("T_myPendingApprovals[End]")).NumberFormat = "m/d/yyyy"
Union(Range("T_myPendingApprovals[Modified]"), Range("T_myPendingApprovals[Created]")).NumberFormat = "m/d/yyyy h:mm"
If Application.WorksheetFunction.CountA(Range("T_myPendingApprovals[Person]")) = 0 Then
Application.StatusBar = False
Application.ScreenUpdating = True
MsgBox "No entries with pending approval existing for you." & vbLf & vbLf & "Your supervisor should enter his name in the column 'Approved by', not you. Only then the records will be displayed in the mail for approval.", vbExclamation, "Approval mail generation"
End
End If
Application.StatusBar = "Step 2/2 - Preparing approval mail..."
SendMail "Request for vacation approval for " & UserNameWindows, _
"Hi ..., <br><br>" & _
"Please approve my vacation as stated below. To evaluate potential capacity issues in the team as well as " & _
"towards important milestones, please refresh your offine copy of the " & _
"<a href=""" & Range("DownloadPage") & """>Team availability Tracker</a> and consider all other parallel vacations in the chart for your approval decision.<br><br>" & _
"Please enter your name in the column approver on the " & _
"<a href=""" & Range("ApprovalView") & """>SharePoint</a>. " & _
"Please do not just reply on this mail, make use of the SharePoint for 100% traceability and do the update(s) there. Only if the name of the supervisor appears in the column '[last] modified by', the approval can be considered as valid. Use the voting button to indicate that the approval took place.<br><br>Best regards,<br>" & FirstName _
, , , , Export_Range_asImage(Range("T_myPendingApprovals[#All]"))
End Sub
我在代码的最后一行收到运行时错误(应用程序定义或对象定义错误)。
Range("T_myPendingApprovals[#All]").ListObject.Refresh
T_myPendingApprovals[#All]”在“我的待审批”工作表中被命名为范围
【问题讨论】:
-
为什么不直接刷新列表对象的全名?
-
你能举个例子吗? @QHarr