• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Schedule Open particular file

Abhijeet

Active Member
Hi

I have macro that open particular file please tell me how to close that file after particular time
Code:
Dim TimeToRun

Sub auto_open()
    Call ScheduleCopyPriceOver
End Sub

Sub ScheduleCopyPriceOver()
    TimeToRun = Now + TimeValue("00:02:00")
    Application.OnTime TimeToRun, "CopyPriceOver"
End Sub

Sub CopyPriceOver()
'    Calculate
'    Range("c7").Value = Range("d7").Value
    Workbooks.Open "C:\Users\swami\Desktop\1M&N.xls"
    Call ScheduleCopyPriceOver
End Sub

Sub auto_close()
    On Error Resume Next
    Application.OnTime TimeToRun, "CopyPriceOver", , False
End Sub
 
Please open the file using following code:
Dim wb As Workbook
Set wb = Workbooks.Open("C:\Users\swami\Desktop\1M&N.xls")


Once job is done you can close it using:
wb.Close
Set wb = Nothing
 
For open file i use This Macro
Code:
Sub ScheduleCopyPriceOver()
    TimeToRun = Now + TimeValue("00:02:00")
    Application.OnTime TimeToRun, "CopyPriceOver"
End Sub

Please tell me for Close file how to use Schedule time
 
Can any one please tell me how to do this i want 1st Open the file in 10 min then close that file after 5 min then after 5 min again open that file same loop till the time macro will not stop
 
Back
Top