Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JB JB is offline
external usenet poster
 
Posts: 115
Default RUNTIME 1004

Worksheet A is saving every 5 seconds. Worksheet B is refreshing links from
A every "x" seconds. When these events occur concurrently, I get a pop-up
asking that I select the source file (A) that was not found during the macro.
If I cancel out, it yields a 1004 error.

Any ideas of how to get around the "error"? (the error occurs in the top of
the code (filename))


ActiveWorkbook.UpdateLink Name:= _
"\\DTCNAS-ILSP002\Mandatory\Analysts - Working Files\Josh\Live Market
Securities.xls" _
, Type:=xlExcelLinks
Range("A1").Select

Call UpdateTime
End Sub


Sub UpdateTime()

Application.OnTime Now + TimeValue("00:00:01"), "UpdateLinks"
'On Error Resume Next


End Sub

Thanks in advance....
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default RUNTIME 1004

You need to dis-synchronize the events. It is easier to do this than test
for conflicts.

Run the save and refresh both at 10 second intervals, but offset them by 5
seconds.
--
Gary''s Student - gsnu200759


"JB" wrote:

Worksheet A is saving every 5 seconds. Worksheet B is refreshing links from
A every "x" seconds. When these events occur concurrently, I get a pop-up
asking that I select the source file (A) that was not found during the macro.
If I cancel out, it yields a 1004 error.

Any ideas of how to get around the "error"? (the error occurs in the top of
the code (filename))


ActiveWorkbook.UpdateLink Name:= _
"\\DTCNAS-ILSP002\Mandatory\Analysts - Working Files\Josh\Live Market
Securities.xls" _
, Type:=xlExcelLinks
Range("A1").Select

Call UpdateTime
End Sub


Sub UpdateTime()

Application.OnTime Now + TimeValue("00:00:01"), "UpdateLinks"
'On Error Resume Next


End Sub

Thanks in advance....

  #3   Report Post  
Posted to microsoft.public.excel.programming
JB JB is offline
external usenet poster
 
Posts: 115
Default RUNTIME 1004

Thanks for the reply.

How do I go about the offset when the files are opened independently and the
save/refresh occur begin at different time intervals?

"Gary''s Student" wrote:

Community Message Not Available

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default RUNTIME 1004

Clunky, but...

On Error Resume Next ' Set Inline Error handling

Do
' Guaranteed to go though loop at least once.
' Will repeat loop only if error is encountered on previous pass.
Err.Clear 'Resets Err.Number to 0 (if it wasn't already)
ActiveWorkbook.UpdateLink Name:= _
"\\DTCNAS-ILSP002\Mandatory\Analysts - Working Files\Josh\Live Market
Securities.xls", Type:=xlExcelLinks
Do Events
Loop While Err.Number < 0

On Error GoTo [??]

If you go this route, consider adding a "retry" counter and then displaying
an error message & exiting if it gets too high (ex: if the file gets
renamed, you'll be in an endless loop otherwise).

Also consider replacing "Do Events" or extending the idea to include a
specific duration with a Sleep/Wait routine like
http://www.mvps.org/access/api/api0021.htm

Observation: saving a file can take a while. Certainly longer than 5
seconds, especially on my network :-)

--
HTH,
George


"JB" wrote in message
...
Worksheet A is saving every 5 seconds. Worksheet B is refreshing links
from
A every "x" seconds. When these events occur concurrently, I get a pop-up
asking that I select the source file (A) that was not found during the
macro.
If I cancel out, it yields a 1004 error.

Any ideas of how to get around the "error"? (the error occurs in the top
of
the code (filename))


ActiveWorkbook.UpdateLink Name:= _
"\\DTCNAS-ILSP002\Mandatory\Analysts - Working Files\Josh\Live Market
Securities.xls" _
, Type:=xlExcelLinks
Range("A1").Select

Call UpdateTime
End Sub


Sub UpdateTime()

Application.OnTime Now + TimeValue("00:00:01"), "UpdateLinks"
'On Error Resume Next


End Sub

Thanks in advance....



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
Runtime 1004 Len B Excel Programming 2 February 21st 07 01:28 AM
runtime 1004 error Janis Excel Programming 3 September 14th 06 09:52 PM
runtime 1004 error Janis Excel Programming 3 September 14th 06 08:09 PM
Runtime error 1004 Terry K Excel Programming 2 September 7th 05 09:57 PM
runtime error 1004 Adella Excel Programming 2 July 29th 03 08:07 PM


All times are GMT +1. The time now is 06:49 PM.

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

About Us

"It's about Microsoft Excel"