Thank you very much for the example.
Here is what I found.
After reading the file I wasn't closing the file.
Then I was trying to write back to the same file using fso.OpenTextFile(WScript.Arguments(0), 2, True,0).Write txtFile
I believe that because I was not closing the file after reading...
Well the files are not empty. I have a 32kb and an 18kb file I am testing with that has data.
These files I receive I have no control over. I just have to make them work.
I did notice when I write back to the file is when I have a problem.
Keep getting invalid procedure call on this line...
Sorry. That was left overs from what I was trying using a line by line read till end of stream. It got messy though.
Anyway, ignore that.
The line is question is strSource = fso.OpenTextFile(WScript.Arguments(0)).ReadAll
Error: input past end of file
code 800a003e
Here is the original...
IM back.
I keep running into EOF errors.
I have tried diffrent ways, but it keeps messing up my file format.
Any ideas.
Dim mytextfile
Dim newtext
Set fso = CreateObject("Scripting.FileSystemObject")
Dim myReplacer
dim strSource
Set myReplacer = New reHelper
strSource = ReadEntireFile...
Ok, New problem.
Any idea how to use regex in vbs to remove null char. Least thats how notepad++ shows them.
See screenshot. http://files.engineering.com/getfile.aspx?folder=bbd30bd6-600c-469d-8805-48dbc0525b12&file=nullcharremove.PNG...
Thanks All. You are correct. The screenshot has the wrong font type. My Mistake. Although it does look the same way using a Monospaced font.
Strongm you are correct. "Balance SBCS characters and DBCS characters" seems to be the issue. Any Idea how to script turning that off. I can only find how...
Just in case anyone is curious, the script in vb to create the word file and set the expanded spacing is as follows:
Function ConvertTxtToWord(TxtFilePath)
Dim objshell,ParentFolder,BaseName,wordapp,doc,WordFilePath,objDoc
Dim objSelection
Set objshell=...
Here is a screenshot. I am thinking something is wrong with my install now as the setting dont save. I have to change them everytime.
http://files.engineering.com/getfile.aspx?folder=41851edd-fb3f-45cf-a400-f17b5504e4fd&file=font_settings1.PNG...
Ok I did the same thing no effect till I changed the other settings.....That is going to make me nutty.
I appreciate all of your help and sticking with me through this.
Okay so I finally figured it out. I tried multiple editors. word, WPS,openoffice. All do the same thing.
First of course select your monospaced font and text size.
I then had to Go into font settings of the Office suite you decide to use.
Turn off Font Kerning and change the font space setting...
Yes Courier is a monospace font. However in windows word, it is monospace only in height for some reason, not width.
I have tested a bunch of monospace fonts and they all have the same symptom.
I found on stock exchange someone was having the same problem, but with a diffrent program...
Ok, so turns out I made an assumption...and we all know what that does.
I compared the text file hidden chars with the word file hidden chars.
They are the same. There is no tab char, only spaces.
So I have been researching MONOSPACE Fonts. Looks like they are not working correctly in word...
I wanted to use word because that is what is on everyone desktop. This will not be for my use but our data clerks.
Notepad and notepad++ dont recognize page breaks. Word does. I am up for suggestions. I did try mono space fonts. Doesn't fix it :(
The text file come from an asa/400 with old line...
I have a text file that I need some users to open in word.
I created the file via VBScript.
In notepad or notepad++ the file looks great.
Open the same file in word and the tab spacing is all messed up. Some times items in a row are single tabbed, or triple tabbed.
What can I do to make it...
Tried that. I just get error line 23.
What Found I could do though, since writing it in notepad++, I can hold alt, type 012 release alt and it inserts Page break FF. I can then copy the pagebreak FF and paste it in quotes and it works !
I also now have it saving as DOC and I am working on...
Ok. So I think I need to set encoding on the file or something. Its just a text file.
I tried chr(12) but it just shows chr(12) in notepad++ and word. No actual page break.
You guys have been great.
StrongGM thank you for your example.
The one piece I was missing was regex.multiline.
The only problem I have now is inserting a page break.
If I use regEx.Replace(fso.OpenTextFile(WScript.Arguments(0)).ReadAll, "ch(12)")
instead of inserting the page break it...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.