PC Review


Reply
Thread Tools Rate Thread

ActiveWorkbook.Save - adds quotation marks to the file content

 
 
SK
Guest
Posts: n/a
 
      24th Jul 2009
Far from an expert in this field, but I use a small Excel macro run trough a text file in order to correct some data.

In principle it is not more complicated than the string below :

Sub Tidy_up_my_file

Selection.Replace What:="BETWEEN PT", Replacement:="BETWEEN", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True

ActiveWorkbook.Save

ActiveWorkbook.Close True

End Sub

However, by some reason the command ActiveWorkbook.Save adds the double quotation marks on some lines in the txt-file (as line 4, 5 and 6 below).


:20:NONREF
:25:025121215508036
:28C:BETWEEN 129/1
":60F:C090701DKK4732,19"
":62F:C090701DKK4732,19"
":64:C090701DKK4732,19"
-}{5:}



Anyone having a clue what to do here? The question is in other words - how to do to avoid getting these quotation marks when saving the file?

Thanks in advance for your support.

/Steve

 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      24th Jul 2009
There is no reason to put text data into a workbook to change the file.
Excel often makes changes to the text when you don't want changes. Instead
open the file as text and make the changes.

Sub Gettext()

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Dim Data(8)

'default folder
Folder = "C:\temp"
ChDir (Folder)

Set fsread = CreateObject("Scripting.FileSystemObject")
FName = Application.GetOpenFilename("Text (*.txt),*.txt")

Set fread = fsread.GetFile(FName)
Set tsread = fread.OpenAsTextStream(ForReading, TristateUseDefault)

FName = Application.GetSaveAsFilename("Text (*.txt),*.txt")

fswrite.CreateTextFile WritePathName
Set fwrite = fswrite.GetFile(FName)

RowCount = 1
Do While tsread.atendofstream = False

InputLine = tsread.ReadLine
Outputline = Replace(InputLine, "BETWEEN PT", "BETWEEN")
tswrite.writeline Outputline

Loop
tsread.Close
fswrite.Close
End Sub



"SK" wrote:

> Far from an expert in this field, but I use a small Excel macro run trough a text file in order to correct some data.
>
> In principle it is not more complicated than the string below :
>
> Sub Tidy_up_my_file
>
> Selection.Replace What:="BETWEEN PT", Replacement:="BETWEEN", LookAt:= _
> xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
> ReplaceFormat:=True
>
> ActiveWorkbook.Save
>
> ActiveWorkbook.Close True
>
> End Sub
>
> However, by some reason the command ActiveWorkbook.Save adds the double quotation marks on some lines in the txt-file (as line 4, 5 and 6 below).
>
>
> :20:NONREF
> :25:025121215508036
> :28C:BETWEEN 129/1
> ":60F:C090701DKK4732,19"
> ":62F:C090701DKK4732,19"
> ":64:C090701DKK4732,19"
> -}{5:}
>
>
>
> Anyone having a clue what to do here? The question is in other words - how to do to avoid getting these quotation marks when saving the file?
>
> Thanks in advance for your support.
>
> /Steve
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel adds quotation marks when pasting text Justin Larson Microsoft Excel Misc 6 12th Jan 2009 05:02 PM
SET command adds quotation marks Matt G Microsoft Windows 2000 CMD Promt 2 27th Nov 2007 03:15 AM
Outlook Adds Single Quotation Marks to Mail Recipient Names =?Utf-8?B?UmFuZHlMYWdyb3U=?= Microsoft Outlook Discussion 0 25th Sep 2006 03:25 PM
Removing quotation marks in a txt-file =?Utf-8?B?UmVlZGhpbGw=?= Microsoft Excel Programming 1 28th Jun 2006 08:16 PM
how do I remove quotation marks from .CSV file =?Utf-8?B?UmF0dHk=?= Microsoft Excel Programming 3 23rd Jun 2005 03:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:07 PM.