Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Replace quotes in notepad

I have an excel .txt file that when opened in Notepad sometimes adds qoutes
the beginning of the data which causes a problem when imported into another
application. What I would like to do is open the file in Notepad edit
replace " with nothing and save the file as a .txt.

Any suggestions would be greatly appreciated.

Thanks
Michael
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Replace quotes in notepad

I don't think there is any way to automate Notepad but no need. Read the
file into memory, edit as required, and re-write the file.

Public Sub RemoveQuotes()
Dim sFile As String
Dim sText As String
Dim FF1 As Long

On Error GoTo errH
sFile = "c:\temp\testfile.txt"

FF = FreeFile
Open sFile For Input As #FF
Line Input #FF, sText
Close #FF

sText = Replace(sText, Chr(34), "")

FF = FreeFile
Open sFile For Output As #FF
Print #FF, sText

resClose:
Close #FF

Exit Sub
errH:
MsgBox Err.Description, , "An error occured"
Resume resClose

End Sub

Regards,
Peter T

"Michael" wrote in message
...
I have an excel .txt file that when opened in Notepad sometimes adds qoutes
the beginning of the data which causes a problem when imported into
another
application. What I would like to do is open the file in Notepad edit
replace " with nothing and save the file as a .txt.

Any suggestions would be greatly appreciated.

Thanks
Michael



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Replace quotes in notepad

Thanks for your help with this, unfortunately I am getting a VBA error
message @ Close #FF
sText = Replace(sText, Chr(34), "")
FF = FreeFile
on the replace command. Comile error: Sub or Function not defined.

I have saved the file to C:\Temp and called it testfile.

Any ideas!!

Thanks
Michael

"Peter T" wrote:

I don't think there is any way to automate Notepad but no need. Read the
file into memory, edit as required, and re-write the file.

Public Sub RemoveQuotes()
Dim sFile As String
Dim sText As String
Dim FF1 As Long

On Error GoTo errH
sFile = "c:\temp\testfile.txt"

FF = FreeFile
Open sFile For Input As #FF
Line Input #FF, sText
Close #FF

sText = Replace(sText, Chr(34), "")

FF = FreeFile
Open sFile For Output As #FF
Print #FF, sText

resClose:
Close #FF

Exit Sub
errH:
MsgBox Err.Description, , "An error occured"
Resume resClose

End Sub

Regards,
Peter T

"Michael" wrote in message
...
I have an excel .txt file that when opened in Notepad sometimes adds qoutes
the beginning of the data which causes a problem when imported into
another
application. What I would like to do is open the file in Notepad edit
replace " with nothing and save the file as a .txt.

Any suggestions would be greatly appreciated.

Thanks
Michael




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Replace quotes in notepad

Can't think why you should get a compile error on the line "Close #FF"

Paste the entire routine exactly as you have it in your module

I have saved the file to C:\Temp and called it testfile.

"testfile.txt" I hope, with plenty of quotes in the text.

Regards,
Peter T



"Michael" wrote in message
...
Thanks for your help with this, unfortunately I am getting a VBA error
message @ Close #FF
sText = Replace(sText, Chr(34), "")
FF = FreeFile
on the replace command. Comile error: Sub or Function not defined.

I have saved the file to C:\Temp and called it testfile.

Any ideas!!

Thanks
Michael

"Peter T" wrote:

I don't think there is any way to automate Notepad but no need. Read the
file into memory, edit as required, and re-write the file.

Public Sub RemoveQuotes()
Dim sFile As String
Dim sText As String
Dim FF1 As Long

On Error GoTo errH
sFile = "c:\temp\testfile.txt"

FF = FreeFile
Open sFile For Input As #FF
Line Input #FF, sText
Close #FF

sText = Replace(sText, Chr(34), "")

FF = FreeFile
Open sFile For Output As #FF
Print #FF, sText

resClose:
Close #FF

Exit Sub
errH:
MsgBox Err.Description, , "An error occured"
Resume resClose

End Sub

Regards,
Peter T

"Michael" wrote in message
...
I have an excel .txt file that when opened in Notepad sometimes adds
qoutes
the beginning of the data which causes a problem when imported into
another
application. What I would like to do is open the file in Notepad edit
replace " with nothing and save the file as a .txt.

Any suggestions would be greatly appreciated.

Thanks
Michael






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default Replace quotes in notepad


Sorry I did not make it clear where the error message occurs it is actually
on the line "sText = Replace(sText, Chr(34), "")"
Full code below
Sub RemoveQuotes()
Dim sFile As String
Dim sText As String
Dim FF1 As Long

On Error GoTo errH
sFile = "c:\temp\240908.txt"

FF = FreeFile
Open sFile For Input As #FF
Line Input #FF, sText
Close #FF

sText = Replace(sText, Chr(34), "")

FF = FreeFile
Open sFile For Output As #FF
Print #FF, sText

resClose:
Close #FF

Exit Sub
errH:
MsgBox Err.Description, , "An error occured"
Resume resClose

End Sub
Thanks for your patience
Michael
"Peter T" wrote:

Can't think why you should get a compile error on the line "Close #FF"

Paste the entire routine exactly as you have it in your module

I have saved the file to C:\Temp and called it testfile.

"testfile.txt" I hope, with plenty of quotes in the text.

Regards,
Peter T



"Michael" wrote in message
...
Thanks for your help with this, unfortunately I am getting a VBA error
message @ Close #FF
sText = Replace(sText, Chr(34), "")
FF = FreeFile
on the replace command. Comile error: Sub or Function not defined.

I have saved the file to C:\Temp and called it testfile.

Any ideas!!

Thanks
Michael

"Peter T" wrote:

I don't think there is any way to automate Notepad but no need. Read the
file into memory, edit as required, and re-write the file.

Public Sub RemoveQuotes()
Dim sFile As String
Dim sText As String
Dim FF1 As Long

On Error GoTo errH
sFile = "c:\temp\testfile.txt"

FF = FreeFile
Open sFile For Input As #FF
Line Input #FF, sText
Close #FF

sText = Replace(sText, Chr(34), "")

FF = FreeFile
Open sFile For Output As #FF
Print #FF, sText

resClose:
Close #FF

Exit Sub
errH:
MsgBox Err.Description, , "An error occured"
Resume resClose

End Sub

Regards,
Peter T

"Michael" wrote in message
...
I have an excel .txt file that when opened in Notepad sometimes adds
qoutes
the beginning of the data which causes a problem when imported into
another
application. What I would like to do is open the file in Notepad edit
replace " with nothing and save the file as a .txt.

Any suggestions would be greatly appreciated.

Thanks
Michael








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Replace quotes in notepad

If(?) you are using Excel-97 the "Replace" function is not recognized, to
cater for all versions replace the "Replace" line with the following

#If VBA6 Then
sText = Replace(sText, Chr(34), "")
#Else
sText = Application.Substitute(sText, Chr(34), "")
#End If

If you are using a later version the above won't correct the problem.
Instead look in Tools, References and uncheck any ticked reference marked
"MISSING"

Regards,
Peter T

"Michael" wrote in message
...

Sorry I did not make it clear where the error message occurs it is
actually
on the line "sText = Replace(sText, Chr(34), "")"
Full code below
Sub RemoveQuotes()
Dim sFile As String
Dim sText As String
Dim FF1 As Long

On Error GoTo errH
sFile = "c:\temp\240908.txt"

FF = FreeFile
Open sFile For Input As #FF
Line Input #FF, sText
Close #FF

sText = Replace(sText, Chr(34), "")

FF = FreeFile
Open sFile For Output As #FF
Print #FF, sText

resClose:
Close #FF

Exit Sub
errH:
MsgBox Err.Description, , "An error occured"
Resume resClose

End Sub
Thanks for your patience
Michael
"Peter T" wrote:

Can't think why you should get a compile error on the line "Close #FF"

Paste the entire routine exactly as you have it in your module

I have saved the file to C:\Temp and called it testfile.

"testfile.txt" I hope, with plenty of quotes in the text.

Regards,
Peter T



"Michael" wrote in message
...
Thanks for your help with this, unfortunately I am getting a VBA error
message @ Close #FF
sText = Replace(sText, Chr(34), "")
FF = FreeFile
on the replace command. Comile error: Sub or Function not defined.

I have saved the file to C:\Temp and called it testfile.

Any ideas!!

Thanks
Michael

"Peter T" wrote:

I don't think there is any way to automate Notepad but no need. Read
the
file into memory, edit as required, and re-write the file.

Public Sub RemoveQuotes()
Dim sFile As String
Dim sText As String
Dim FF1 As Long

On Error GoTo errH
sFile = "c:\temp\testfile.txt"

FF = FreeFile
Open sFile For Input As #FF
Line Input #FF, sText
Close #FF

sText = Replace(sText, Chr(34), "")

FF = FreeFile
Open sFile For Output As #FF
Print #FF, sText

resClose:
Close #FF

Exit Sub
errH:
MsgBox Err.Description, , "An error occured"
Resume resClose

End Sub

Regards,
Peter T

"Michael" wrote in message
...
I have an excel .txt file that when opened in Notepad sometimes adds
qoutes
the beginning of the data which causes a problem when imported into
another
application. What I would like to do is open the file in Notepad
edit
replace " with nothing and save the file as a .txt.

Any suggestions would be greatly appreciated.

Thanks
Michael








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA String Output adds Quotes when I cut and paste to Notepad rfusee Excel Programming 1 September 18th 07 08:40 PM
Selection.Replace What and double quotes Ed Peters Excel Programming 5 September 15th 07 03:56 PM
change straight quotes to curly quotes callico Excel Discussion (Misc queries) 2 June 22nd 07 10:23 PM
How do i get historical stock quotes using MSN Money Stock Quotes Ash Excel Discussion (Misc queries) 0 May 11th 06 03:26 AM
NotePad OldCCN Excel Programming 1 July 7th 04 07:40 PM


All times are GMT +1. The time now is 09:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"