(Which will later be inserted into an excel Spread Sheet). I have no problem with
with files contain both. I have attached a folder containing one file with returns
set source_folder to choose folder
tell application "Finder"
set file_list to files in source_folder
end tell
repeat with this_file in file_list
set Title to this_file as text
set AppleScript's text item delimiters to "Macintosh HD:Users:thomas:Desktop:test folder:"
set Title1 to text item 2 of Title
set AppleScript's text item delimiters to ""
tell application "Microsoft Word"
open (this_file as alias)
set myDoc to active document
select myDoc
set Acctinfo to content of text object of selection
display dialog ">>>" & Acctinfo & "<<<"
close documents saving no
end tell
set {lf, retx} to {ASCII character 10, ASCII character 13}
set Multieol to false
if Acctinfo contains lf and Acctinfo contains retx then
display dialog "has both LF and retx"
set eol to lf & retx
set Multieol to true
else
if Acctinfo contains lf then
display dialog "has LF"
set eol to lf
else
if Acctinfo contains retx then
display dialog "has return"
set eol to retx
else
display dialog "Has neither"
end if
end if
end if
--if eol ≠ "Both" then
if not Multieol then
set AppleScript's text item delimiters to eol
set allines to Acctinfo's text items
set Numlnes to (count allines)
display dialog "Number of lines pre reduction=" & Numlnes
end if
--if eol = "Both" then
if Multieol then
display dialog "File " & Title1 & " Has Both CR LF"
set AppleScript's text item delimiters to eol
set lnefield to text items of Acctinfo
set AppleScript's text item delimiters to tab
set goodline to lnefield as string
display dialog "goodline=" & goodline
else
set Icount to 1
set goodline to Title1 & tab
set GoodFields to 0
repeat Numlnes - 1 times
set AppleScript's text item delimiters to eol
set lnefield to text item Icount of Acctinfo
if lnefield ≠ "" then
set goodline to goodline & lnefield & tab
set GoodFields to GoodFields + 1
end if
set Icount to Icount + 1
end repeat
display dialog "Number of Fields After reduction=" & GoodFields
display dialog "goodline=" & goodline
end if
end repeat