Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VBA应用程序。Ontime时间值不运行_Vba_Excel - Fatal编程技术网

VBA应用程序。Ontime时间值不运行

VBA应用程序。Ontime时间值不运行,vba,excel,Vba,Excel,我想每天早上7点完成并发送一份报告。我将Application.Ontime TimeValue7:00:00,DailyReport放入我的代码中。这在过去运行得很好,但在我修改了DailyReport sub中的一些其他代码后,这些代码应该不会影响应用程序。不管怎样,请选择Ontime并使用DDE忽略其他应用程序,该报告将不再在上午7:00发出 非常感谢各位的帮助 Option Explicit Sub DailyReport() Dim t As String 'Time to send

我想每天早上7点完成并发送一份报告。我将Application.Ontime TimeValue7:00:00,DailyReport放入我的代码中。这在过去运行得很好,但在我修改了DailyReport sub中的一些其他代码后,这些代码应该不会影响应用程序。不管怎样,请选择Ontime并使用DDE忽略其他应用程序,该报告将不再在上午7:00发出

非常感谢各位的帮助

Option Explicit

Sub DailyReport()
Dim t As String 'Time to send daily Snapshot
Dim pr As Boolean 'Is process running/is there data for yesterday


ThisWorkbook.UpdateLink Name:="Y:\DATA COLLECTION 2018.xlsx"
Application.Calculate
t = Db.Range("C6").Value()
pr = Db.Range("D5").Value()
Db.ChartObjects("Chart 1").Chart.Refresh
Db.ChartObjects("Chart 3").Chart.Refresh
Db.ChartObjects("Chart 4").Chart.Refresh


Dim objOutlook As Object
Dim objMail As Object
Dim rng As Range

    today = Format(Now(), "m/dd/yyyy")

    Set objOutlook = CreateObject("Outlook.Application")
    Set objMail = objOutlook.CreateItem(0)
    Set rng = Db.Range("B8:F16")

    Dim myPic1 As String
    Dim myPic2 As String
    Dim myPic3 As String
    Dim fileName1 As String
    Dim fileName2 As String
    Dim fileName3 As String
    Dim myPath As String
    Dim sj As String

    myPic1 = "Feed.png"
    myPic2 = "T and Vacuum.png"
    myPic3 = "D.png"
    myPath = "C:\Users\lab3\Downloads\"

    fileName1 = myPath & myPic1
    fileName2 = myPath & myPic2
    fileName3 = myPath & myPic3
    Db.ChartObjects("Chart 1").Chart.Export fileName1
    Db.ChartObjects("Chart 3").Chart.Export fileName2
    Db.ChartObjects("Chart 4").Chart.Export fileName3

    With objMail
        Dim cell As Range
        Dim strto As String

        For Each cell In Distribution.Range("A1:A100")
            If cell.Value Like "?*@?*.?*" Then
                strto = strto & cell.Value & ";"
            End If
        Next cell

        If Len(strto) > 0 Then strto = Left(strto, Len(strto) - 1)
        If pr Then sj = "Daily Report " & today Else sj = "Daily Report " & today & " - No new data"
            .To = strto
            .Subject = sj
            .HTMLBody = RangetoHTML(rng) & "<p><p>" & "<img src = '" & fileName1 & "'>" & "<p><p>" & _
            "<img src = '" & fileName3 & "'>" & "<p><p>" & "<img src = '" & fileName2 & "'>"
            .Display

   End With


With Application
        .EnableEvents = True
        .ScreenUpdating = True
     End With

    Application.SendKeys "%s"

    Set objOutlook = Nothing
    Set objMail = Nothing


Db.Range("C5").FormulaR1C1 = "TRUE"
Application.StatusBar = "Ready"
ThisWorkbook.Save
Application.OnTime TimeValue("7:00:00"), "DailyReport", True

End Sub
从以下文件记录:

将Schedule设置为false可清除以前使用相同的过程和EarliestTime值设置的过程

但在我修改了DailyReport sub中的一些其他代码之后,您到底修改了什么代码?请更新您的问题,让我们知道。