LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default macro timer

Hi,
my problem refers to the code below.
It applies on two files (A.xls, B.xls).
My goal is as follow: i want to open the first file
(it updates by DDE) and, after 40 sec., save it and
open the second file and repeat the operations: update
and then, after 40 sec., save it.

But my code opens the two files at the same time.
It saves the last one and then macro stops because
of the error.
I've got a msg: "Run-time error '91'"

I'm looking at the error but I don't see where it
can be... maybe I've used the some wrong
functions.
Could you suggest me something that can help
me ?

Thank you very much,
ap

'-------------------------------------------------
Option Explicit
Public WB As Workbook
Dim arrFiles()
Dim i
'--------------------------------------------------

Public Sub link()

Dim sFile As String
Dim sPath As String

arrFiles = Array("A", "B")
sPath = "C:\FILES\"

For i = 0 To 1
sFile = Dir(sPath & arrFiles(i) & "*.xls")
Workbooks.Open (sPath & arrFiles(i))
open
Next i


End Sub


'---------------------------------------------------

Public Sub open()


Set WB = ActiveWorkbook
Worksheets("Sheet1").Range("AO1:AS38").Calculate

Application.Run (arrFiles(i) & "!" & "DoOnData")
Application.onTime Now + TimeValue("00:00:40"), "saving"

End Sub


'-------------------------------------------------------

Public Sub saving()

WB.Close savechanges:=True
Set WB = Nothing


End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
timer Macro Puzzled Excel Worksheet Functions 3 March 11th 06 09:21 PM
Stopping a Timer / Running a timer simultaneously on Excel Paul23 Excel Discussion (Misc queries) 1 March 10th 06 12:08 PM
timer macro Darren Excel Discussion (Misc queries) 1 January 24th 06 01:59 PM
Macro With Timer Event Saxman Excel Discussion (Misc queries) 4 December 12th 05 05:35 PM
timer within a macro Orlando Magalhães Filho Excel Programming 3 September 6th 03 06:54 PM


All times are GMT +1. The time now is 06:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"