Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,670
Default Does loop function cause this problem?

Once I use the loop function for following codes, I run into problems on
files, such as
1) All files can be read and written in the first place, but somehow I don't
understand why some file type becomes read only. Does the loop cause any
problem by retrieving data too quick while saving and closing processes do
not complete?

2) date from Data file could be retrieved by other application at the same
time, so I set the displayalert to be false, but DisplayAlerts is still pop
up for locating the Data file, any suggestions on what cause this problem?

Does anyone have any suggestions on how to solve this loop problem?
Thank in advance for any suggestions
Eric
-------------------------------------------------------------------------------------
Application.DisplayAlerts = False
{Retrieve the latest date in cell A2 from file Data.xls}
x = TheValue("E:\Files", "Data.xls", "Records", "A2")

[Repeated codes - start]
Do
{Summary file must be opened at least once}
Workbooks.Open Filename:="E:\Files\Summary.xls", UpdateLinks:=3
Workbooks("Summary.xls").Close savechanges:=True
{Retrieve the last updated date in cell A591 from file Summary.xls}
y = TheValue("E:\Files", "Summary.xls", "Records", "A591")
{If the date is different between Data and Summary files, then redo this
step again}
Loop While x < y
[Repeated codes - end]

{This repeated codes will be duplicated 64 times for different files to be
updated}
-------------------------------------------------------------------------------------

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,365
Default Does loop function cause this problem?

I don't see anything that should cause a change in the read status. You say
that they're coming up later as Read Only? Are they actually Read Only (go
to the folder, right click a filename and look at properties, if Read Only is
checked, then they are actually read only - but if it is clear then they are
not read only but Excel is somehow flagging them as "open as read only
recommended").

If the problem is Excel somehow flagging them as 'read only recommended'
then you might try this workaround. Remember that when you do a
Workbooks.Open then that workbook becomes the active workbook and remains the
active workbook until you activate another or close it, and that is the
premise of this workaround code. I introduce a string variable, fName, here
that you may need to declare earlier in the code:

fName = "E:\Files\Summary.xls"
Do
Workbooks.Open Filename:=fName, UpdateLinks:=3
'you've already turned off .DisplayAlerts, so don't have to again here
'assumes the workbook opened above is still the active workbook
ActiveWorkbook.SaveAs Filename:=fName, ReadOnlyRecommended:=False
'continue on with your code using fName instead of literal string where
appropriate



"Eric" wrote:

Once I use the loop function for following codes, I run into problems on
files, such as
1) All files can be read and written in the first place, but somehow I don't
understand why some file type becomes read only. Does the loop cause any
problem by retrieving data too quick while saving and closing processes do
not complete?

2) date from Data file could be retrieved by other application at the same
time, so I set the displayalert to be false, but DisplayAlerts is still pop
up for locating the Data file, any suggestions on what cause this problem?

Does anyone have any suggestions on how to solve this loop problem?
Thank in advance for any suggestions
Eric
-------------------------------------------------------------------------------------
Application.DisplayAlerts = False
{Retrieve the latest date in cell A2 from file Data.xls}
x = TheValue("E:\Files", "Data.xls", "Records", "A2")

[Repeated codes - start]
Do
{Summary file must be opened at least once}
Workbooks.Open Filename:="E:\Files\Summary.xls", UpdateLinks:=3
Workbooks("Summary.xls").Close savechanges:=True
{Retrieve the last updated date in cell A591 from file Summary.xls}
y = TheValue("E:\Files", "Summary.xls", "Records", "A591")
{If the date is different between Data and Summary files, then redo this
step again}
Loop While x < y
[Repeated codes - end]

{This repeated codes will be duplicated 64 times for different files to be
updated}
-------------------------------------------------------------------------------------

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,670
Default Does loop function cause this problem?

I run two excel applications separately, because I get 2 CPUs for my
computer, and assign each excel application for each CPU. Both excel
applications will be opened, save and closed a list of files one by one at
the same time, and all files are referred to Data.xls for retrieving data.
Both application run simultaneously, in the middle of process, one of excel
application stops and pop up an error on macro as show below

Loop While x < y
I receive Error 2023 on x variable
Does anyone have any suggestions on what cause this problem and how to solve
it?
Thank for any suggestions
Eric

"JLatham" wrote:

I don't see anything that should cause a change in the read status. You say
that they're coming up later as Read Only? Are they actually Read Only (go
to the folder, right click a filename and look at properties, if Read Only is
checked, then they are actually read only - but if it is clear then they are
not read only but Excel is somehow flagging them as "open as read only
recommended").

If the problem is Excel somehow flagging them as 'read only recommended'
then you might try this workaround. Remember that when you do a
Workbooks.Open then that workbook becomes the active workbook and remains the
active workbook until you activate another or close it, and that is the
premise of this workaround code. I introduce a string variable, fName, here
that you may need to declare earlier in the code:

fName = "E:\Files\Summary.xls"
Do
Workbooks.Open Filename:=fName, UpdateLinks:=3
'you've already turned off .DisplayAlerts, so don't have to again here
'assumes the workbook opened above is still the active workbook
ActiveWorkbook.SaveAs Filename:=fName, ReadOnlyRecommended:=False
'continue on with your code using fName instead of literal string where
appropriate



"Eric" wrote:

Once I use the loop function for following codes, I run into problems on
files, such as
1) All files can be read and written in the first place, but somehow I don't
understand why some file type becomes read only. Does the loop cause any
problem by retrieving data too quick while saving and closing processes do
not complete?

2) date from Data file could be retrieved by other application at the same
time, so I set the displayalert to be false, but DisplayAlerts is still pop
up for locating the Data file, any suggestions on what cause this problem?

Does anyone have any suggestions on how to solve this loop problem?
Thank in advance for any suggestions
Eric
-------------------------------------------------------------------------------------
Application.DisplayAlerts = False
{Retrieve the latest date in cell A2 from file Data.xls}
x = TheValue("E:\Files", "Data.xls", "Records", "A2")

[Repeated codes - start]
Do
{Summary file must be opened at least once}
Workbooks.Open Filename:="E:\Files\Summary.xls", UpdateLinks:=3
Workbooks("Summary.xls").Close savechanges:=True
{Retrieve the last updated date in cell A591 from file Summary.xls}
y = TheValue("E:\Files", "Summary.xls", "Records", "A591")
{If the date is different between Data and Summary files, then redo this
step again}
Loop While x < y
[Repeated codes - end]

{This repeated codes will be duplicated 64 times for different files to be
updated}
-------------------------------------------------------------------------------------

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,365
Default Does loop function cause this problem?

As this is a different question than your original, you may want to repost it
as a topic of its own.

I've not tried running 2 instances of Excel on a dual core system, so I
don't have any experience in that area. Have you checked the values of X and
Y when the error occurs? Choose [Debug] and use the Immediate Window to seen
their values. You mention that both instances are using one file, Data.xls,
for retrieving data - I suspect that both instances trying to access the same
file and perhaps the same data item in that file may be part of the problem.
But that's just a guess.

"Eric" wrote:

I run two excel applications separately, because I get 2 CPUs for my
computer, and assign each excel application for each CPU. Both excel
applications will be opened, save and closed a list of files one by one at
the same time, and all files are referred to Data.xls for retrieving data.
Both application run simultaneously, in the middle of process, one of excel
application stops and pop up an error on macro as show below

Loop While x < y
I receive Error 2023 on x variable
Does anyone have any suggestions on what cause this problem and how to solve
it?
Thank for any suggestions
Eric

"JLatham" wrote:

I don't see anything that should cause a change in the read status. You say
that they're coming up later as Read Only? Are they actually Read Only (go
to the folder, right click a filename and look at properties, if Read Only is
checked, then they are actually read only - but if it is clear then they are
not read only but Excel is somehow flagging them as "open as read only
recommended").

If the problem is Excel somehow flagging them as 'read only recommended'
then you might try this workaround. Remember that when you do a
Workbooks.Open then that workbook becomes the active workbook and remains the
active workbook until you activate another or close it, and that is the
premise of this workaround code. I introduce a string variable, fName, here
that you may need to declare earlier in the code:

fName = "E:\Files\Summary.xls"
Do
Workbooks.Open Filename:=fName, UpdateLinks:=3
'you've already turned off .DisplayAlerts, so don't have to again here
'assumes the workbook opened above is still the active workbook
ActiveWorkbook.SaveAs Filename:=fName, ReadOnlyRecommended:=False
'continue on with your code using fName instead of literal string where
appropriate



"Eric" wrote:

Once I use the loop function for following codes, I run into problems on
files, such as
1) All files can be read and written in the first place, but somehow I don't
understand why some file type becomes read only. Does the loop cause any
problem by retrieving data too quick while saving and closing processes do
not complete?

2) date from Data file could be retrieved by other application at the same
time, so I set the displayalert to be false, but DisplayAlerts is still pop
up for locating the Data file, any suggestions on what cause this problem?

Does anyone have any suggestions on how to solve this loop problem?
Thank in advance for any suggestions
Eric
-------------------------------------------------------------------------------------
Application.DisplayAlerts = False
{Retrieve the latest date in cell A2 from file Data.xls}
x = TheValue("E:\Files", "Data.xls", "Records", "A2")

[Repeated codes - start]
Do
{Summary file must be opened at least once}
Workbooks.Open Filename:="E:\Files\Summary.xls", UpdateLinks:=3
Workbooks("Summary.xls").Close savechanges:=True
{Retrieve the last updated date in cell A591 from file Summary.xls}
y = TheValue("E:\Files", "Summary.xls", "Records", "A591")
{If the date is different between Data and Summary files, then redo this
step again}
Loop While x < y
[Repeated codes - end]

{This repeated codes will be duplicated 64 times for different files to be
updated}
-------------------------------------------------------------------------------------

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
Function problem PE Excel Discussion (Misc queries) 2 April 19th 07 03:36 PM
Mid Function Problem DEI Excel Discussion (Misc queries) 3 August 9th 06 08:08 PM
Problem with IF function [email protected] Excel Discussion (Misc queries) 5 January 19th 06 04:11 PM
Find and Copy loop problem BillyJ Excel Discussion (Misc queries) 3 November 2nd 05 07:16 PM
FV Function Problem TerryG Excel Worksheet Functions 3 June 13th 05 09:26 PM


All times are GMT +1. The time now is 09:16 PM.

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"