Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Macro running with files on a server

6 views
Skip to first unread message

Brian Cecava

unread,
Nov 14, 2000, 3:00:00 AM11/14/00
to
I am putting together a WP8 macro that will run on a server
continuously. The macro will check a LAN directory for files and open
the documents once they are copied to the LAN directory from another
process on a different server.

My question is how do I know when the files are done being copied to the
LAN directory from the other process and I can grab them with my WP8
macro (FileOpen)? If I get the file to quick, I will get the error
"This document is in use or is specified as read-only. You may edit the
document, but you must save it with a new name. Continue?"

In M$ Word when I tried to open a file that was not done copying, I
would get an error number that I could interrogate.

In WP8 I can't find any command or system variable to check on if it is
OK to open a file after all the contents of the file have been copied to
a directory.

Do I have to use the FileSize command to check for a certain size of the
file before I try to open it?

Thanks!
--
Brian Cecava
Ameritas Life Insurance Corp.
http://www.ameritas.com

Charles E Finkenbiner

unread,
Nov 21, 2000, 3:00:00 AM11/21/00
to
Hi Brian,

Have you tried the OnError statement to try to trap the error message?


Hope this helps,

CEF

"Brian Cecava" <bce...@ameritas.com> wrote in message
news:3A11436F...@ameritas.com...

Brian Cecava

unread,
Nov 21, 2000, 3:00:00 AM11/21/00
to
Charles,

I have not tried the OnError statement. Would the code look something like
this?

Application (WP; "WordPerfect"; Default!; "EN")

OnError call (FileOpenError)
while (FileOpen("ABC.WPD"))
endwhile
OnError ()

Procedure FileOpenError()
MessageBox or write to log file about error opening file. Will retry.

EndProc

Brian

Charles E Finkenbiner

unread,
Nov 21, 2000, 3:00:00 AM11/21/00
to
Hi Brian,

Yes, you got it. I am not sure the OnError will trap this kind of error but
it is worth a try. Depending on whether you want an error message displayed
or a log file created you could just loop, with no error message, until the
file is done or you could display the error message for 2 or 3 seconds and
then try to access the file again.


Hope this helps,

CEF

"Brian Cecava" <bce...@ameritas.com> wrote in message

news:3A1A96F8...@ameritas.com...

Charles E Finkenbiner

unread,
Nov 21, 2000, 3:00:00 AM11/21/00
to
Hi Brian,

One thing I forgot to mention, a Procedure is not really required unless you
plan on passing values back and forth. A label should work just fine.
Really, either way should work.


CEF

"Charles E Finkenbiner" <Char...@MailandNews.Com> wrote in message
news:3a1ad2c4@cnews...

Charles E Finkenbiner

unread,
Nov 21, 2000, 3:00:00 AM11/21/00
to
Hi Brian,

I overlooked something in my earlier post. When you 'Call' a procedure or
label, the way you want to use it in your code, you need to have a 'Return'
statement at the end. This will allow the loop you are looking for, until
the file is finished being copied.


Hope this helps,

CEF

"Charles E Finkenbiner" <Char...@MailandNews.Com> wrote in message

news:3a1ad6f8@cnews...

Chip Orange

unread,
Dec 1, 2000, 3:00:00 AM12/1/00
to
Well, if nothing else works, you could take two looks at the file size,
separated by some reasonable time (at least a second) to see if it hasn't
changed.

HTH,

Chip Orange

James M Moore

unread,
Dec 7, 2000, 3:00:00 AM12/7/00
to
Here is a sample of code I created.
x:= "->"
repeat
prompt( x)
hFile:=OpenFile (Name:"C:\copy of a.txt"; AccessMode:Read!;
ShareMode:Exclusive!; DataType:AnsiText!)
x:= "-"+ X
Until( hFile > 0)
CloseFile( HFile)
//do something now that you know the file is ready
the above will make an arrow in a little dialog box, showing you that the
macro is indeed working, until the copy is complete and the file can be
worked on. All you need is the following:

repeat
hFile:=OpenFile (Name:"C:\copy of a.txt"; AccessMode:Read!;
ShareMode:Exclusive!; DataType:AnsiText!)
Until( hFile > 0)
CloseFile( HFile)

The above assumes the file exists. If there is a chance that the file
doesn't even exist, check to see if hFile = -1 after the OpenFile command,
as in:

repeat
hFile:=OpenFile (Name:"C:\copy of a.txt"; AccessMode:Read!;
ShareMode:Exclusive!; DataType:AnsiText!)
If( hFile = -1)
//we know that the file doesn't exist. Do something special?
EndIf
Until( hFile > 0)
CloseFile( HFile)

Have a nice day!

James

JamesMM.vcf
0 new messages