file size

  • Thread starter Thread starter Rudy W.
  • Start date Start date
R

Rudy W.

In my database I export a query to a MS Excel file, then
that Excel file is compressed (with
WinZip/WinRar/7Zip/...) and finaly the compressed file is
attached in a mail and send to a mailbox.

Everything works, except this: when the Excel file is
about 1200 Kb or bigger, the compress program has not
finished at the moment the file is attached in the mail.

So I need to know when the compressing is finished before
the file is attached in the mail.
I could do this by:

1) checking if the size of the compressed file stops
growing.
Question, how do I get the file size?

2) checking if the compress program has finished its work.
Question: how can the output of a process (compress
application) started by a batchfile in the Shell command
be intercepted and checked?

Thanks
 
Hello,
Im familiar with that problem...here is what I did

'Add wait period for zip file to be created
If Len(Dir(Trim(Source))) > 0 Then
waiting& = FileLen(Source) / 1000000
End If

WaitDelay (waiting&)

Public Function WaitDelay(Optional iTime As Integer = 5)
Dim DelayEnd As Double
DelayEnd = DateAdd("s", iTime, Now)
Do Until DateDiff("s", Now, DelayEnd) <= 0
Loop
End Function
 
The FileLen() function returns the length of a file in
bytes.
eg) x = FileLen("C:\Db1.mdb")

Just divide the result by 1024 to get Kilobytes.

When I run batch files, I have them generate a 'trigger'
file at the end.
eg) echo Pings Completed >c:\AllDone.txt

I use a timer event to check for the existance of that
trigger file to determine if my batch program has finished
executing, then kill the trigger file to reinitialize for
next use.
eg) Kill "c:\AllDone.txt"
 
Thanks Elwin, Deville and Cheryl,

Every answer gave a posible good solution.
In the meantime I found an other one:

The compress program moves the .xls file.
So testing if the .xls file was is gone seems a very easy
solution:

varExcelName = Dir(cExportPath & varFileName & ".xls",
vbDirectory)
Do While varExcelName <> ""
varExcelName = Dir(cExportPath & varFileName & ".xls",
vbDirectory)
Loop

Rudy W.
 
I don't understand why you have the vbDirectory in there if you're looking
for a file, not a directory. I'd suggest adding a DoEvents in there.
Finally, a real trivial point: it's more efficient to check that the length
of the string is 0 rather than compare it to a constant ""

varExcelName = Dir(cExportPath & varFileName & ".xls")
Do While Len(varExcelName) > 0
varExcelName = Dir(cExportPath & varFileName & ".xls")
DoEvents
Loop
 
Back
Top