Daniel2001
02-25-2008, 05:03 AM
Hi I have two workbooks wkb1 ,wkb2,
I wanna open them at different scheduled time ,but application.ontime can only be written once in Excel.
so I am trying to open wkb1 on schedule time, then before it closes itself, wkb1 open wkb2. wkb2 will first close wkb1 ,then run the rest of the code. The problem is when wkb2 close wkb1, nothing continues...looks like everything stops as wkb1 closes
wkb1 code
Private Sub Workbook_Open()
Range("a1").Value = 1
Workbooks.Open Filename:="C:\wkb2.xls"
End Sub
wkb2 code
Private Sub Workbook_Open()
Dim wkb1 As Workbook
set wkb1 = workbooks("wkb1.xls")
wkb1.save
wkb1.close ' Here is where everything stops...the rest of the code doesn't run
Workbooks("wkb2.xls").Activate
ActiveSheet.Range("a1").Value = 2
ThisWorkbook.Close
End Sub
please advise on this:hi:
I wanna open them at different scheduled time ,but application.ontime can only be written once in Excel.
so I am trying to open wkb1 on schedule time, then before it closes itself, wkb1 open wkb2. wkb2 will first close wkb1 ,then run the rest of the code. The problem is when wkb2 close wkb1, nothing continues...looks like everything stops as wkb1 closes
wkb1 code
Private Sub Workbook_Open()
Range("a1").Value = 1
Workbooks.Open Filename:="C:\wkb2.xls"
End Sub
wkb2 code
Private Sub Workbook_Open()
Dim wkb1 As Workbook
set wkb1 = workbooks("wkb1.xls")
wkb1.save
wkb1.close ' Here is where everything stops...the rest of the code doesn't run
Workbooks("wkb2.xls").Activate
ActiveSheet.Range("a1").Value = 2
ThisWorkbook.Close
End Sub
please advise on this:hi: