Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This line :
Print #OutFile, Replace(Input(LOF(InFile), #InFile), "1LS-Arial", "1LS-OCR-B-10 BT") needs to be all one line. The news reader wrapped it. NickHK "NickHK" wrote in message ... I can't repeat your error(s) using this code your XML file. It replaces fine, no Chinese or errors. Dim InFile As Long Dim OutFile As Long InFile = FreeFile Open "C:\Replace.txt" For Input As #InFile OutFile = FreeFile Open "C:\outdat.txt" For Output As #OutFile Print #OutFile, Replace(Input(LOF(InFile), #InFile), "1LS-Arial", "1LS-OCR-B-10 BT") Close #InFile Close #OutFile As for the files, whilst they may be text, they can still be saved in a Unicode format. Open in NotePad, do a SaveAs and check the Encoding setting. However, I get different errors to those you mentioned if the file is Unicode. NickHK "pieros" wrote in message oups.com... Good morning NickHK (It now is here about 08:40 am), My text files are good readable characters. Here is an example: <?xml version="1.0"? <DynaMark-Project title="Sjabloon_40mm_Rb.xml" version="0.1" <Dynamark-Object type="CObjText" <CObjBaseData template-version="0.1" <ObjName type="CString"ExpDate</ObjName <ParamDelaysName type="CString"KM09standaard</ParamDelaysName <Invers type="bool" value="false"/ <Mark type="bool" value="true"/ <Offset type="CPoint" value="-1908788 -725252"/ <ScaleX type="double" value="1.8"/ <ScaleY type="double" value="2.2"/ <RadiantX type="double" value="-1.5708"/ <RadiantY type="double" value="-1.5708"/ <MirrorX type="bool" value="true"/ <MirrorY type="bool" value="true"/ <LaserNr type="int" value="0"/ <MinVectorLength type="double" value="0"/ <XCenterMode type="int" value="0"/ <YCenterMode type="int" value="0"/</CObjBaseData <CObjText <Text type="CString"2222222</Text <FontName type="CString"1LS-Arial</FontName And than about 100 - 120 lines for each file. So there seems nothing wrong with the text. My goal is to replace the text 1LS-Arial or 1LS-Arial-U in 1LS-OCR-B-10 BT in each file but in some files the text 1LS-OCR-B-10 BT is already present so needs no modification. Pieros. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() NickHK I'm sorry but when I use this code Option Explicit '*********************** Programma schrijft alleen de 1e 100 regels naar het aangegeven file - de laatste regel niet helemaal compleet ??????? ** Sub read_file() Dim InFile As Long Dim OutFile As Long InFile = FreeFile Open "U:\Programs - Documents\MSExcel\Test zoek en vervang 4 - aangepast volgens forum\Approved\Cop00004500\00004583_001_KART_KM9_V 1.xml" For Input As #InFile OutFile = FreeFile Open "U:\Programs - Documents\MSExcel\Test zoek en vervang 4 - aangepast volgens forum\Corrected\Cop00004500\00004583_001_KART_KM9_ V1.xml" For Output As #OutFile Print #OutFile, Replace(Input(LOF(InFile), #InFile), "1LS-Arial", "1LS-OCR-B-10 BT") Close #InFile Close #OutFile End Sub I get the Run-time Error 62 again. (Input past end of file) My text replacement wish is not a simple one I believe. Pieros |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you get that error, then you have text files with Unicode encoding. As
such, this code will not work. You can adapt this : http://support.microsoft.com/kb/193540 Or maybe use the FSO: http://www.aivosto.com/visdev/fso.html However, as your file are XML, you can open them directly in XL2002. However, with your file, I get an error, as the first line "<?xml version="1.0"?" is invalid. Not sure how Excel would handle the encoding either. NickHK "pieros" wrote in message oups.com... NickHK I'm sorry but when I use this code Option Explicit '*********************** Programma schrijft alleen de 1e 100 regels naar het aangegeven file - de laatste regel niet helemaal compleet ??????? ** Sub read_file() Dim InFile As Long Dim OutFile As Long InFile = FreeFile Open "U:\Programs - Documents\MSExcel\Test zoek en vervang 4 - aangepast volgens forum\Approved\Cop00004500\00004583_001_KART_KM9_V 1.xml" For Input As #InFile OutFile = FreeFile Open "U:\Programs - Documents\MSExcel\Test zoek en vervang 4 - aangepast volgens forum\Corrected\Cop00004500\00004583_001_KART_KM9_ V1.xml" For Output As #OutFile Print #OutFile, Replace(Input(LOF(InFile), #InFile), "1LS-Arial", "1LS-OCR-B-10 BT") Close #InFile Close #OutFile End Sub I get the Run-time Error 62 again. (Input past end of file) My text replacement wish is not a simple one I believe. Pieros |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Anyway, thanks NickHK for your help sofar. I will try what you suggest
and hope it will work. Thanks again, Pieros. NickHK wrote: If you get that error, then you have text files with Unicode encoding. As such, this code will not work. You can adapt this : http://support.microsoft.com/kb/193540 Or maybe use the FSO: http://www.aivosto.com/visdev/fso.html However, as your file are XML, you can open them directly in XL2002. However, with your file, I get an error, as the first line "<?xml version="1.0"?" is invalid. Not sure how Excel would handle the encoding either. NickHK |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
command line options/switches to print excel file | Excel Worksheet Functions | |||
command line options/switches to print excel file | Excel Discussion (Misc queries) | |||
how to print a sheet by command | Excel Discussion (Misc queries) | |||
How to format the extension less file to print with Dos's Print Command | Excel Discussion (Misc queries) | |||
Create command button to print multiple worksheets in a excel file | Excel Discussion (Misc queries) |