Results 1 to 6 of 6

Thread: Help with VBA timin issue on task scheduler

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    5
    Rep Power
    0

    Angry Help with VBA timin issue on task scheduler

    Hi,
    I have obtained this VBA from the forum and have tried to changed it for my needs but whatever I do doesn't seem to work.

    Can anyone out there see where I have gone wrong. When Task scheduler runs, I want it to run 3 macros if the time is before 6.30am but only run 2 after that. It will open the Excel file at 6am, but nothing seems to happen as the excel report remains open unti I arrive into work.

    Code:
    Private Sub TestInteractive()
    Application.DisplayAlerts = False
    If GetActiveWindow() = 0 Then
    ' We're running via the Task Scheduler: Update the Spreadsheet/Graph
    If Workbooks.Count = 1 Then
    If TimeValue(Now()) <= TimeValue("06:30:00") Then
    Call Macro3
    Call Hide
    Call Mail_Sheet_Outlook_Body
    ActiveWorkbook.Save
    Application.Quit
    Else
    If GetActiveWindow() = 0 Then
    ' We're running via the Task Scheduler: Update the Spreadsheet/Graph
    If Workbooks.Count = 1 Then
    Call Hide
    Call Mail_Sheet_Outlook_Body
    ActiveWorkbook.Save
    Application.Quit
    Else
    Me.Close True 'save the changes and close the workbook
    Application.DisplayAlerts = True
    End If
    End If
    End If
    End If
    End If
    End Sub

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,122
    Rep Power
    10
    Hi

    Welcome to forum !

    What happens if you run it manually (Pressing F8) by skipping the time criteria?
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  3. #3
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    12
    Code:
    If
    
    Elseif
    
    Else
    
    End if

  4. #4
    Junior Member
    Join Date
    Feb 2013
    Posts
    5
    Rep Power
    0
    Hi snb,

    The vb worked perfectly before I put the timing issue i, before all I needed was to run the sheet once, which created a new column for the current days information. Now I have to run it more than once per day, I don't want a new column created every time I run it.

    I know I have probably made this more complicated than it needs to be as I am not very prificient at VB. I managed to get this far by manipulating VB that I found on the internet.

    As for your suggestion to skip the timing criteria, I have no way of understanding where to put this within the VB I have. But thanks for the reply and at least thinking of a way round it.

  5. #5
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,122
    Rep Power
    10
    Hi

    It's a Cross Post

    Please read Message to cross posters in my signature
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  6. #6
    Junior Member
    Join Date
    Feb 2013
    Posts
    5
    Rep Power
    0
    Hi,

    Sorry, didn't realise both forums were linked, I have posted this on the Ozgrid forum.

    VBA time value for task scheduler

    Thanks

Similar Threads

  1. vba, worksheet visible issue
    By xander1981 in forum Excel Help
    Replies: 1
    Last Post: 03-13-2014, 04:06 PM
  2. Date COlumn AutoFiltering Issue!
    By labkhand in forum Excel Help
    Replies: 3
    Last Post: 11-06-2013, 01:41 AM
  3. Replies: 9
    Last Post: 08-05-2013, 11:28 PM
  4. Warning Alerts Depending On Time Remaining To Finish Task
    By peter renton in forum Excel Help
    Replies: 9
    Last Post: 06-19-2013, 12:20 PM
  5. SharePoint Hyperlink issue
    By PeteRooney in forum Excel Help
    Replies: 0
    Last Post: 10-30-2012, 03:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •