PC Review


Reply
Thread Tools Rate Thread

How to add condition within macro?

 
 
Eric
Guest
Posts: n/a
 
      19th Nov 2009
Does anyone have any suggestion on how to add condition within macro?
I would like to add coding only run TurnOffPC only after 4 pm
Does anyone have any suggestions?
Thank everyone very much for any suggestions
Eric

Sub mycoding
....
....

TurnOffPC;
End Sub


'*******************SHUT DOWN*********************
Sub TurnOffXP()
'shutdown.exe will NOT work on Windows 95, 98, 98 SE and ME
ActiveWorkbook.Save
Application.DisplayAlerts = False
Application.Quit
'//shut down the computer
Shell "shutdown -s -t 02", vbHide
End Sub

Sub TurnOffPC()
Dim Action As Long
ActiveWorkbook.Save
Application.DisplayAlerts = False
'//shut down the computer
Action = ExitWindowsEx(EWX_SHUTDOWN, 0&)
Application.Quit
End Sub
'***************************************************

 
Reply With Quote
 
 
 
 
Sam Wilson
Guest
Posts: n/a
 
      19th Nov 2009
sub MyCoding
....
if hour(now)>16 then TurnOffPC

End sub

"Eric" wrote:

> Does anyone have any suggestion on how to add condition within macro?
> I would like to add coding only run TurnOffPC only after 4 pm
> Does anyone have any suggestions?
> Thank everyone very much for any suggestions
> Eric
>
> Sub mycoding
> ...
> ...
>
> TurnOffPC;
> End Sub
>
>
> '*******************SHUT DOWN*********************
> Sub TurnOffXP()
> 'shutdown.exe will NOT work on Windows 95, 98, 98 SE and ME
> ActiveWorkbook.Save
> Application.DisplayAlerts = False
> Application.Quit
> '//shut down the computer
> Shell "shutdown -s -t 02", vbHide
> End Sub
>
> Sub TurnOffPC()
> Dim Action As Long
> ActiveWorkbook.Save
> Application.DisplayAlerts = False
> '//shut down the computer
> Action = ExitWindowsEx(EWX_SHUTDOWN, 0&)
> Application.Quit
> End Sub
> '***************************************************
>

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      19th Nov 2009
Eric,

You need to ONTIME method. Change MyMacro to the name of yopur code and it
will run at 4 0 clock

Private Sub Workbook_Open()
Application.OnTime TimeValue("16:00:00"), "MyMacro"
End Sub

Mike

"Eric" wrote:

> Does anyone have any suggestion on how to add condition within macro?
> I would like to add coding only run TurnOffPC only after 4 pm
> Does anyone have any suggestions?
> Thank everyone very much for any suggestions
> Eric
>
> Sub mycoding
> ...
> ...
>
> TurnOffPC;
> End Sub
>
>
> '*******************SHUT DOWN*********************
> Sub TurnOffXP()
> 'shutdown.exe will NOT work on Windows 95, 98, 98 SE and ME
> ActiveWorkbook.Save
> Application.DisplayAlerts = False
> Application.Quit
> '//shut down the computer
> Shell "shutdown -s -t 02", vbHide
> End Sub
>
> Sub TurnOffPC()
> Dim Action As Long
> ActiveWorkbook.Save
> Application.DisplayAlerts = False
> '//shut down the computer
> Action = ExitWindowsEx(EWX_SHUTDOWN, 0&)
> Application.Quit
> End Sub
> '***************************************************
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Condition in macro Eva Microsoft Access 1 23rd Oct 2009 06:41 PM
Using a Where condition in a Macro =?Utf-8?B?SnVzdGluODM3MTY=?= Microsoft Access Form Coding 2 17th Apr 2007 07:16 PM
macro condition =?Utf-8?B?Sm9obiAoQmlnIEd1eSk=?= Microsoft Access Macros 4 9th Aug 2005 06:41 PM
macro to run only under certain condition - how? Orion Microsoft Excel Programming 2 22nd Dec 2004 10:08 AM
condition in Macro Ian Microsoft Access Macros 1 19th Nov 2003 11:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:37 PM.