Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default On.Time problem

I have some workbooks which contain links to an external data retrieval
service. When a file is opened it takes about 30 seconds for that linked data
to be updated.

My objective is to open each file in turn, wait untill the data comes in
(say 30 seconds), convert the linked cells to values so that they are no
longer volatile and finally save the file to a different folder.

I have no difficulty doing the entire process in a loop EXCEPT that I have a
problem with introducing that delay between each pass of the loop which is
absolutely essential.

The WAIT method does not work because it locks up the machine and prevents
the data from coming in. I have used the ON.TIME method in the past to
trigger a partucular procedure but I'm not sure how to apply it to introduce
a delay between each pass of the loop.

Any other suggestions would be appreciated.

THANK YOU
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default On.Time problem

Ben,

give this a try. Create a new module and paste the code below. You run it
by calling the ProcessFiles subroutine. It works by having the files to be
opened in a collection object. Each file is then opened and "waits" 5
seconds by using OnTime, and then closes the workbook and opens the next
one... and so on.

you'll need to change the part where the files are put in the collection and
you'll need to put your code in the part after the workbook is opened.


Private colFiles As Collection
Private iIndex As Integer
Private curWB As Workbook
Sub ProcessFiles()

Set colFiles = New Collection
Set curWB = Nothing
iIndex = 1

'put all files in the colFiles collection here.
'replace this part with your code
colFiles.Add "D:\TEMP\book1.xls"
colFiles.Add "D:\TEMP\book2.xls"


'Start "looping".
If colFiles.Count 0 Then
OpenFiles
End If

End Sub
Sub OpenFiles()
Dim NextTime As Date


'if a workbook is open, work with it.
If Not curWB Is Nothing Then
'do something with the workbook.
'30 second delay would have expired by now.

'when done. close the workbook and set curwb to nothing
curWB.Close
Set curWB = Nothing
'increment the Index
iIndex = iIndex + 1
End If

'we are done.
If iIndex colFiles.Count Then Exit Sub

If curWB Is Nothing Then
'there is no current workbook. open a new one
Set curWB = Workbooks.Open(colFiles(iIndex))
End If

NextTime = Now + TimeValue("00:00:05")
Application.OnTime NextTime, "OpenFiles"

End Sub




--
Hope that helps.

Vergel Adriano


"Ben" wrote:

I have some workbooks which contain links to an external data retrieval
service. When a file is opened it takes about 30 seconds for that linked data
to be updated.

My objective is to open each file in turn, wait untill the data comes in
(say 30 seconds), convert the linked cells to values so that they are no
longer volatile and finally save the file to a different folder.

I have no difficulty doing the entire process in a loop EXCEPT that I have a
problem with introducing that delay between each pass of the loop which is
absolutely essential.

The WAIT method does not work because it locks up the machine and prevents
the data from coming in. I have used the ON.TIME method in the past to
trigger a partucular procedure but I'm not sure how to apply it to introduce
a delay between each pass of the loop.

Any other suggestions would be appreciated.

THANK YOU

  #3   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default On.Time problem

That was helpful, Thank you

"Ben" wrote:

I have some workbooks which contain links to an external data retrieval
service. When a file is opened it takes about 30 seconds for that linked data
to be updated.

My objective is to open each file in turn, wait untill the data comes in
(say 30 seconds), convert the linked cells to values so that they are no
longer volatile and finally save the file to a different folder.

I have no difficulty doing the entire process in a loop EXCEPT that I have a
problem with introducing that delay between each pass of the loop which is
absolutely essential.

The WAIT method does not work because it locks up the machine and prevents
the data from coming in. I have used the ON.TIME method in the past to
trigger a partucular procedure but I'm not sure how to apply it to introduce
a delay between each pass of the loop.

Any other suggestions would be appreciated.

THANK YOU

  #4   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default On.Time problem

Vergel, I have one more request. As part of the solution, you suggest
creating a collection as follows: colFiles.Add "D:Temp\book.xls" ... etc
Instead of explicitly specifying each file I'd like specify one folder and
then add all the files in that folder to colFiles.

Thanks again

"Ben" wrote:

That was helpful, Thank you

"Ben" wrote:

I have some workbooks which contain links to an external data retrieval
service. When a file is opened it takes about 30 seconds for that linked data
to be updated.

My objective is to open each file in turn, wait untill the data comes in
(say 30 seconds), convert the linked cells to values so that they are no
longer volatile and finally save the file to a different folder.

I have no difficulty doing the entire process in a loop EXCEPT that I have a
problem with introducing that delay between each pass of the loop which is
absolutely essential.

The WAIT method does not work because it locks up the machine and prevents
the data from coming in. I have used the ON.TIME method in the past to
trigger a partucular procedure but I'm not sure how to apply it to introduce
a delay between each pass of the loop.

Any other suggestions would be appreciated.

THANK YOU

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default On.Time problem

Ben,

try this

Dim colFiles As New Collection
Dim strPath As String
Dim strFile As String

strPath = "D:\TEMP\"

strFile = Dir(strPath)

While strFile < ""
colFiles.Add strPath & strFile
strFile = Dir
Wend

--
Hope that helps.

Vergel Adriano


"Ben" wrote:

Vergel, I have one more request. As part of the solution, you suggest
creating a collection as follows: colFiles.Add "D:Temp\book.xls" ... etc
Instead of explicitly specifying each file I'd like specify one folder and
then add all the files in that folder to colFiles.

Thanks again

"Ben" wrote:

That was helpful, Thank you

"Ben" wrote:

I have some workbooks which contain links to an external data retrieval
service. When a file is opened it takes about 30 seconds for that linked data
to be updated.

My objective is to open each file in turn, wait untill the data comes in
(say 30 seconds), convert the linked cells to values so that they are no
longer volatile and finally save the file to a different folder.

I have no difficulty doing the entire process in a loop EXCEPT that I have a
problem with introducing that delay between each pass of the loop which is
absolutely essential.

The WAIT method does not work because it locks up the machine and prevents
the data from coming in. I have used the ON.TIME method in the past to
trigger a partucular procedure but I'm not sure how to apply it to introduce
a delay between each pass of the loop.

Any other suggestions would be appreciated.

THANK YOU

Reply
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
Time problem Jon New Users to Excel 1 June 3rd 09 08:38 AM
Time problem - Help please sawagashi Excel Discussion (Misc queries) 7 November 18th 05 10:15 PM
Time Problem B. Baumgartner Excel Discussion (Misc queries) 2 June 30th 05 09:05 PM
Time Problem Ian Gilmore[_2_] Excel Programming 1 November 6th 04 02:20 AM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM


All times are GMT +1. The time now is 06:30 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"