Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove blank line/carriage return from exported txt file

Status
Not open for further replies.

maggieb

IS-IT--Management
Jun 26, 2001
50
US
I am updating some access 2003 databases to 2007. I have been using the following code to remove the blank line at the end of an exported text file:

stAppName = "c:\windows\notepad.exe t:\user\ach\export.txt"
returnvalue = Shell(stAppName, 1)
AppActivate returnvalue
SendKeys "^{END}"
SendKeys "{backspace}"
SendKeys "%{F4}", True
SendKeys "{ENTER}"

Is there a better way of doing this - i'd like to eliminate the sendkeys....
 
try
Code:
Dim FileText As String
Dim FileName As String

FileName = "t:\user\ach\export.txt"
Open FileName For Input As #1
FileText = Input(LOF(1), #1)
Close #1
FileText = Left(FileText, LOF(1) - 2)
Open FileName For Output As #1
Print #1, FileText
Close #1
 
Thanks, pwise - I tried this method, but it still adds a blank line/line feed to the end of the file. I'll keep messing with it though!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top