I like to import a csv-file containing sales order data into the Navision tabels Sales Header and Sales Line. My interface using a dataport worked fine until the codepage of the files have been switched from ASCII to UTF8.
Does anybody know, how to convert a UTF8-coded file into an ANSI or ASCII-coded file ?
I tried already to open the file within a report via Excel and save it again with the OpenText- and SaveAs-methods of Excel (see the follwing code).
IF ISCLEAR(Excel) THEN CREATE(Excel,FALSE);
Excel.Visible(TRUE);
Excel.Workbooks.OpenText(FileName, //Dateiname
65001, //Codepage UTF8
1, //Startrow
1, //Excel.Workbooks.XlTextParsingType.xlDelimited
//Konstante für den variable dateityp CSV-Datei
3, //Excel.XLTextQualifier.xlTextQualifierNone
//Konstante für den Feldbegrenzer
FALSE, //Aufeinanderfolgende Trennzeichen als ein Zeichen behandeln?
FALSE, //Kein Tab als Trennzeichen
TRUE, //Semikolon als Trennzeichen
FALSE, //Kein Komma als Trennzeichen
FALSE, //Kein Space als Trennzeichen
FALSE); //Kein anderes Trennzeichen
Book := Excel.ActiveWorkbook;
Book.SaveAs(FileName, //Dateiname
6, //Dateiformat: 6 = CSV-Datei
'', //Password für Leseschutz
'', //Password für Schreibschutz
FALSE, //ReadOnlyRecommended: falls True wird beim Öffnen eine Schreibschutzabfrage
//eingeblendet
FALSE, //CreateBackup: Falls True wired eine Sicherungskopie erstellt
1, //XLSaveAsAccessMode: Speichert den Öffnen-Modus einer Datei
//Der Wert 1 für Standard, d.h. den Modus beim Speichern nicht ändern
2); //XlConfictResolution: Der Wert 2 für "Akzeptiere die Änderungen"
Excel.Quit;
CLEAR(Excel);
But i couldn't automate this indirect way, because I couldn't find a method to suppress the standard user dialog windows, which Excel uses to submit confirm messages to the user.
Has anybody a better idea ?
Jochen Anderko
New every month!
Exclusive products and attractive prizes for our newsletter subscribers.
Just sign in here:
http://www.lh-worldshop.com/newsletter-en.html0
Comments
It's a possible solution.
Freelance Dynamics AX
Blog : http://axnmaia.wordpress.com/
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
A little help how to use it can be seen in comments section of. http://dynamicsuser.net/blogs/nunomaia/ ... icode.aspx
Freelance Dynamics AX
Blog : http://axnmaia.wordpress.com/
there you can change the encoding.
http://savatage99.googlepages.com/Encoding.JPG
http://www.BiloBeauty.com
http://www.autismspeaks.org
The only new feature is the capability using automation, nothing else.
Freelance Dynamics AX
Blog : http://axnmaia.wordpress.com/