-1
I have a macro that takes a file inside a folder, converts it from txt with fixed width to csv and saves it in another folder. I get about 400 to 450 files in this format for conversion, the macro got very large and divided into 4 parts. until ai ok pq works well, but there is a variation in the example files: last month I received the file djacy_txt and this month I did not receive, so when the macro arrives in the file djacy_txt and does not find it to tell me that there was an error because it did not find the file.
would like to know how I do to put a (if
) in the macro p that she does so:
if you find the file XXXX.txt do (conversion macro) or search for next file.
<
Workbooks.OpenText Filename:="P:\MACRO P CONVERSÃO\VBA\BRUTO\djacy.txt", _
Origin:=xlMSDOS, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array( _
Array(0, 1), Array(5, 1), Array(12, 1), Array(20, 1), Array(29, 1), Array(31, 1), Array(76, _
1), Array(87, 1), Array(92, 1), Array(93, 1), Array(104, 1), Array(107, 1), Array(113, 1), _
Array(125, 1), Array(145, 1)), TrailingMinusNumbers:=True
Columns("O:O").Select
Selection.ClearContents
Range("Q5").Select
ActiveWindow.SmallScroll Down:=-18
dirCopia = "P:\MACRO P CONVERSÃO\VBA\CONVERTIDO\"
nomeCopia = "djacy"
ActiveWorkbook.SaveAs Filename:= _
dirCopia + nomeCopia, _
FileFormat:=xlCSV, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Workbooks("marcelo.csv").Close SaveChanges:=False
>
THANK YOU! I made a script in 5 parts to name each file, more the way Voce set up the loop I only need 1 template for each layout!
– Djacy Neto