Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I've the following sub to read all files in a specific folder. For some reason (probably because the files are shared) there are junk files in the folder (starts with ~$ and filesize is 0kb). The sub fails because of these files. How do I modify the sub so it doesn't try to read these files?
Thanks,
Jonas
Sub readFiles (root)
For each File in filelist (root & '\*.xlsx')
Npi_Bom_template:
LOAD RecNo() as counterBOM,
ASMBLY,
fileName() as [Project Name],
PART,
QTY,
CUSTPN
From [$(File)] (ooxml, embedded labels, header is 4 lines, table is [BOM-Report]);
Next File;
End sub;
Call readFiles ('S:\_Bom_Reports');
what about disregarding ~$ files, using sth like this:
Sub readFiles (root)
For each File in filelist (root & '\*.xlsx')
vsFileCheck = index(File,'~$');
if vsFileCheck=0 then
Npi_Bom_template:
LOAD RecNo() as counterBOM,
ASMBLY,
fileName() as [Project Name],
PART,
QTY,
CUSTPN
From [$(File)] (ooxml, embedded labels, header is 4 lines, table is [BOM-Report]);
endif
Next File;
End sub;
Call readFiles ('S:\_Bom_Reports');
Hi.
You can either check the file size with FileSize() function before load or modify the wildcard in "filelist (root & '\*.xlsx')" to consider only files having some permanent prefix.
what about disregarding ~$ files, using sth like this:
Sub readFiles (root)
For each File in filelist (root & '\*.xlsx')
vsFileCheck = index(File,'~$');
if vsFileCheck=0 then
Npi_Bom_template:
LOAD RecNo() as counterBOM,
ASMBLY,
fileName() as [Project Name],
PART,
QTY,
CUSTPN
From [$(File)] (ooxml, embedded labels, header is 4 lines, table is [BOM-Report]);
endif
Next File;
End sub;
Call readFiles ('S:\_Bom_Reports');