Problem with ontime.application

  • Hello.


    I wrote this code in the Code of Sheet1

    Code
    Sub Macro1()
    ThisWorkbook.Sheets(Array("Sheet1")).Select
    ActiveSheet.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            Filename:="C:\test\upload\sample.pdf", _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, _
            OpenAfterPublish:=False
    End Sub


    I would like to run this every 5 minutes so I wrote this code and put it in ThisWorkbook

    Code
    Sub Schedulemacro()
            Application.OnTime Now + TimeValue("00:05:00"), "Blad27.Macro1"
    End Sub


    The problem is that this ran once but the next 5 minutes the code won't run.


    What did I wrong ? What can I do to solve this ?


    Thanks.

  • Re: Problem with ontime.application


    Aftr the macro1 has finished, you want to do it again right? So just add

    Code
    call Schedulemacro


    before End Sub inside Macro1

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!