if oFolder.Count = 0 then
msgbox("devotion har postat i fel forum ;-)")
else
....
end if
edit: satte rätt namn på objektet med alla filer
2 svar · 569 visningar · startad av devotion
Hej!
Jag har följande kod:
Sub main()
dim oFS, oFolder, oFile
dim re, sTaskNr, line, nArtr, nAmount
dim m
Set oFS=CreateObject("Scripting.FileSystemObject")
if oFS.FolderExists(Application.Setting("CommonPath") & "Import\Articles\ImportFiles") then
set oFolder = oFS.GetFolder(Application.Setting("CommonPath") & "Import\Articles\ImportFiles").files
for each oFile in oFolder
msgBox oFile.name
set re = new regexp
set oFile = oFS.opentextfile((Application.Setting("CommonPath") & "Import\Articles\ImportFiles\" & oFile.name & ""), 1)
while not oFile.AtEndOfStream
'Första raden
if oFile.line = 1 then
line = oFile.ReadLine
re.pattern = "\d+"
if re.test(line) then
set sTaskNr = re.execute(line)(0)
msgBox sTaskNr
else
'Error!
end if
else
'De andra raderna..
line = oFile.ReadLine
re.pattern = "^%([^#]+)#\t(\d+)$"
set m = re.execute(line)
if m.Count = 1 then
nArtr = m(0).submatches(0)
nAmount = m(0).submatches(1)
msgBox "artikelnummer: " & nArtr & " Antal: " & nAmount
end if
end if
wend
next
else
'wee
end if
End sub
Hur kompletterar man den att kontrollera om det finns några filer i angiven mapp?
Om det inte gör det ska en messageBox visas? :)
Mvh
Henrik
if oFolder.Count = 0 then
msgbox("devotion har postat i fel forum ;-)")
else
....
end if
edit: satte rätt namn på objektet med alla filer
Thanx.. ;)