E
Ed
I query an old database which yields an Access-like table output. I convert
this to a tab-delimited DOS .txt file. I then open this text file in Word
and run a macro which loops through the text file making separate Word docs.
The first steps of the loop are to select the first grouping (a report
number), and use it to compare each line until it changes; this selection is
also used as the file name when the new document is saved.
Since this takes about two hours to run, I set it to start when I'm leaving
for the day, and let a separate program shut off my computer. One day I
forgot to set my shut-off, and noticed the macro was stalled on an error. A
bit of investigation showed that my converted .txt file has a garbage
non-text character as the last line (it looks like a little square). The
actual query output ends in a filled table row, so apparently the conversion
adds this below the last line of text.
I'm thinking I should delete that character before running the rest of the
macro, just to avoid the error. Since I can't guarantee that this character
will always be there, or will only be just one character or just one line, I
'm wondering how best to approach this. Can I add something that looks at
the initial selection to see if it is valid text - if yes, continue - if
not, delete and end sub? Or is there a better way?
Ed
this to a tab-delimited DOS .txt file. I then open this text file in Word
and run a macro which loops through the text file making separate Word docs.
The first steps of the loop are to select the first grouping (a report
number), and use it to compare each line until it changes; this selection is
also used as the file name when the new document is saved.
Since this takes about two hours to run, I set it to start when I'm leaving
for the day, and let a separate program shut off my computer. One day I
forgot to set my shut-off, and noticed the macro was stalled on an error. A
bit of investigation showed that my converted .txt file has a garbage
non-text character as the last line (it looks like a little square). The
actual query output ends in a filled table row, so apparently the conversion
adds this below the last line of text.
I'm thinking I should delete that character before running the rest of the
macro, just to avoid the error. Since I can't guarantee that this character
will always be there, or will only be just one character or just one line, I
'm wondering how best to approach this. Can I add something that looks at
the initial selection to see if it is valid text - if yes, continue - if
not, delete and end sub? Or is there a better way?
Ed