I'm a beginner so I start simple. Why is this not working and how can I fix it? Been at this a whole week, cant sleep guys!
*I need a CSV file to UTF-8 with BOM to ANSI.
*I am hoping to use VBA to solve this.
*Alternatively VB Script (open file in notebook, save as ANSI - can this be coded? Works fine manualy)
Notes:
1. When I do this manualy it works fine.
- Open file in Excel, go threw the display options, save as CSV with Semicolon seperation.
2. When I record my actions it does not save properly.
- It changes ";" to "," and decimal from "," to ".".
3. The idea is that I will build the action into a loop and converge a set of CSV files. I can share this code when I get this to work.
Greetings from Norway
Untouched.csv CSV UTF-8 with BOM
Goal.csv ANSI, done manualy by open and save Excel-file og open in notebook and save with ANSI.
Attempt with macro.csv ANSI, by macro recorder, se errors
Straight from macro recorder:
*I need a CSV file to UTF-8 with BOM to ANSI.
*I am hoping to use VBA to solve this.
*Alternatively VB Script (open file in notebook, save as ANSI - can this be coded? Works fine manualy)
Notes:
1. When I do this manualy it works fine.
- Open file in Excel, go threw the display options, save as CSV with Semicolon seperation.
2. When I record my actions it does not save properly.
- It changes ";" to "," and decimal from "," to ".".
3. The idea is that I will build the action into a loop and converge a set of CSV files. I can share this code when I get this to work.
Greetings from Norway
Untouched.csv CSV UTF-8 with BOM
Rich (BB code):
Sideetikett;Art. nr.;Type;Length;Hight;With;Thickness;Utstøping;Concrete
BA-E01;5031;Utstøping B30;23,12;0;0;0,25;32,49;8,12
BA-E02;5601;Dekke;12,34;0,4;0,3;0,25;;
BA-E03;5034;Dekke;11,2;0;0;0,25;5,96;1,49
BA-E04;5031;Utstøping B30;7,51;0;0;0,25;2,24;0,56
BA-E05;5033;Utstøping B45;6,8;0;0;0,25;1,85;0,46
BA-E06;5031;Dekke;6,54;0;0;0,27;1,41;0,38
BA-E07;5014;Dekke;6,47;0;0;0,25;;
BA-E08;5031;Utstøping bad B30;4,59;0;0;0,19;0,89;0,17
BA-E09;5079;Dekke;3,14;0;0;0;0,45;0
BA-E10;5604;Beam;3,03;0;0;0,25;;
BA-E11;5086;Dekke;2,35;0;0;0,25;;
BA-E12;5086;Dør;2,32;0;0;0,25;;
BA-E13;5086;Dør;2,14;0;0;0,25;;
BA-E14;2082;Dør;1,8;0;0;0,25;;
BA-E15;5600;Søyle;1,59;0,4;0,3;0,25;;
BA-E16;5084;Dekke;1,59;0;0;0,25;;
Goal.csv ANSI, done manualy by open and save Excel-file og open in notebook and save with ANSI.
Rich (BB code):
Sideetikett;Art. nr.;Type;Length;Hight;With;Thickness;Utstøping;Concrete
BA-E01;5031;Utstøping B30;23,12;0;0;0,25;32,49;8,12
BA-E02;5601;Dekke;12,34;0,4;0,3;0,25;;
BA-E03;5034;Dekke;11,2;0;0;0,25;5,96;1,49
BA-E04;5031;Utstøping B30;7,51;0;0;0,25;2,24;0,56
BA-E05;5033;Utstøping B45;6,8;0;0;0,25;1,85;0,46
BA-E06;5031;Dekke;6,54;0;0;0,27;1,41;0,38
BA-E07;5014;Dekke;6,47;0;0;0,25;;
BA-E08;5031;Utstøping bad B30;4,59;0;0;0,19;0,89;0,17
BA-E09;5079;Dekke;3,14;0;0;0;0,45;0
BA-E10;5604;Beam;3,03;0;0;0,25;;
BA-E11;5086;Dekke;2,35;0;0;0,25;;
BA-E12;5086;Dør;2,32;0;0;0,25;;
BA-E13;5086;Dør;2,14;0;0;0,25;;
BA-E14;2082;Dør;1,8;0;0;0,25;;
BA-E15;5600;Søyle;1,59;0,4;0,3;0,25;;
BA-E16;5084;Dekke;1,59;0;0;0,25;;
Attempt with macro.csv ANSI, by macro recorder, se errors
Rich (BB code):
Sideetikett,Art. nr.,Type,Length,Hight,With,Thickness,Utstøping,Concrete
BA-E01,5031,Utstøping B30,23.12,0,0,0.25,32.49,8.12
BA-E02,5601,Dekke,12.34,0.4,0.3,0.25,,
BA-E03,5034,Dekke,11.2,0,0,0.25,5.96,1.49
BA-E04,5031,Utstøping B30,7.51,0,0,0.25,2.24,0.56
BA-E05,5033,Utstøping B45,6.8,0,0,0.25,1.85,0.46
BA-E06,5031,Dekke,6.54,0,0,0.27,1.41,0.38
BA-E07,5014,Dekke,6.47,0,0,0.25,,
BA-E08,5031,Utstøping bad B30,4.59,0,0,0.19,0.89,0.17
BA-E09,5079,Dekke,3.14,0,0,0,0.45,0
BA-E10,5604,Beam,3.03,0,0,0.25,,
BA-E11,5086,Dekke,2.35,0,0,0.25,,
BA-E12,5086,Dør,2.32,0,0,0.25,,
BA-E13,5086,Dør,2.14,0,0,0.25,,
BA-E14,2082,Dør,1.8,0,0,0.25,,
BA-E15,5600,Søyle,1.59,0.4,0.3,0.25,,
BA-E16,5084,Dekke,1.59,0,0,0.25,,
Straight from macro recorder:
VBA Code:
Sub Makro1()
Workbooks.OpenText Filename:="C:\Users\FR\Downloads\Untouched.csv", _
Origin:=65001, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=True, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _
Array(9, 1)), TrailingMinusNumbers:=True
ChDir "C:\Users\FR\Downloads"
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\FR\Downloads\Attempt with macro.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveWindow.Close
End Sub