Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() How can I read a mulitple line in a text file and then print it as single line? eg... she is beautiful output as... she is beautifu -- JaiJa ----------------------------------------------------------------------- JaiJai's Profile: http://www.excelforum.com/member.php...fo&userid=1948 View this thread: http://www.excelforum.com/showthread.php?threadid=48388 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
a = "She is"
b = "beautiful" msgbox a & " " & b -- Regards, Tom Ogilvy "JaiJai" wrote in message ... How can I read a mulitple line in a text file and then print it as a single line? eg... she is beautiful output as... she is beautiful -- JaiJai ------------------------------------------------------------------------ JaiJai's Profile: http://www.excelforum.com/member.php...o&userid=19484 View this thread: http://www.excelforum.com/showthread...hreadid=483888 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() No, I need to write a vba like open ObjOut For Output As #2 Line Input #1, data Close don't want to use msgbox.... since the input text file is not really simply,it may vary in number of lines.... -- JaiJai ------------------------------------------------------------------------ JaiJai's Profile: http://www.excelforum.com/member.php...o&userid=19484 View this thread: http://www.excelforum.com/showthread...hreadid=483888 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() the input file is can i write print file as follows: Open textfile For Output As #2 TextToFind = "greece" Do While Not EOF(1) Line Input #1, data If InStr(1, data, TextToFind) Then Print #2, data End If Loop Close the input textfile file is "fdsfsdfsdf fdsgfsdfsdf dfssafsdf greece gree tyyyy iolololololololo" i want the output file is greece gree tyyyy iolololololololo I want to print file from "greece" and print the rest of files a SINGLE line -- JaiJa ----------------------------------------------------------------------- JaiJai's Profile: http://www.excelforum.com/member.php...fo&userid=1948 View this thread: http://www.excelforum.com/showthread.php?threadid=48388 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() besides, how can i print out "greece gree tyyyy iolololololololo" in the first line of the output text file BUT the original output text file has letters already. I don't want the original letters being removed but instead just insert "greece gree tyyyy iolololololololo" in the first line. -- JaiJai ------------------------------------------------------------------------ JaiJai's Profile: http://www.excelforum.com/member.php...o&userid=19484 View this thread: http://www.excelforum.com/showthread...hreadid=483888 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() anyone can help? it is very urgen -- JaiJa ----------------------------------------------------------------------- JaiJai's Profile: http://www.excelforum.com/member.php...fo&userid=1948 View this thread: http://www.excelforum.com/showthread.php?threadid=48388 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In the example
Source.txt contains the line with Greece in it Source1.txt is the data that will be placed after the concatenated Greece line in a new file Dest.Txt is the new file that will contained the joined data set. Sub AdjustFiles() Dim SourceNum As Integer Dim DestNum As Integer Dim SourceNum1 as Integer Dim bFound as Boolean Dim Temp As String ' If an error occurs, close the files ' and end the macro. On Error GoTo ErrHandler ' Open the destination text file. DestNum = FreeFile() Open "DEST.TXT" For Output As DestNum ' Open the source text file. SourceNum = FreeFile() Open "SOURCE.TXT" For Input As SourceNum SourceNum1 = FreeFile() Open "SOURCE1.TXT" For Input As SourceNum bFound = False Do While Not EOF(SourceNum) Line Input #SourceNum, Temp If InStr(1, Temp, "greece", vbTextCompare) Then sStr = Temp & " " Elseif bFound sStr = sStr & Temp ' write concatenated data to Dest.txt Print #DestNum, sStr ' quit reading from Source.Txt Exit Do End If Loop ' now append data from Source1.txt to DEST.txt Do While Not EOF(SourceNum1) Line Input #SourceNum1, Temp Print #DestNum, Temp Loop CloseFiles: ' Close the destination file and the source file. Close #DestNum Close #SourceNum Close #SourceNum1 Exit Sub ErrHandler: MsgBox "Error # " & Err & ": " & Error(Err) Resume CloseFiles End Sub Once you are sure it does what you want, you can then add code to delete Source1.txt and rename Dest.txt to Source1.txt -- Regards, Tom Ogilvy "JaiJai" wrote in message ... anyone can help? it is very urgent -- JaiJai ------------------------------------------------------------------------ JaiJai's Profile: http://www.excelforum.com/member.php...o&userid=19484 View this thread: http://www.excelforum.com/showthread...hreadid=483888 |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() thanks a lot but one more thing he Is there any scripts for inserting the target line in the orginal tex file? that is : target statement is "greece" The original text output file is: fsdfsfsf gdfgs dfsafdgfd After running the scripts, then the output text file is (while keepin the original content): greece fsdfsfsf gdfgs dfsafdgf -- JaiJa ----------------------------------------------------------------------- JaiJai's Profile: http://www.excelforum.com/member.php...fo&userid=1948 View this thread: http://www.excelforum.com/showthread.php?threadid=48388 |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() is it that no method for inserting the statement into a textfile (original has content)? I just keep the remaining and original content in the text file but with a new statement inserted in the first line in this output file. -- JaiJai ------------------------------------------------------------------------ JaiJai's Profile: http://www.excelforum.com/member.php...o&userid=19484 View this thread: http://www.excelforum.com/showthread...hreadid=483888 |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can you insert a line at the top of an existing text file that has no
specific structure. No. You would have to write the combined file, then copy it back over the original. -- Regards, Tom Ogilvy "JaiJai" wrote in message ... is it that no method for inserting the statement into a textfile (original has content)? I just keep the remaining and original content in the text file but with a new statement inserted in the first line in this output file. -- JaiJai ------------------------------------------------------------------------ JaiJai's Profile: http://www.excelforum.com/member.php...o&userid=19484 View this thread: http://www.excelforum.com/showthread...hreadid=483888 |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try the following code:
Dim InFNum As Integer: InFNum = 1 Dim OutFNum As Integer: OutFNum = 2 Dim OutFName As String Dim InFName As String Dim S As String Dim WholeS As String InFName = "H:\test.txt" '<< Change OutFName = "H:\out.txt" '<< Change Open InFName For Input As InFNum Do Until EOF(InFNum) Line Input #InFNum, S WholeS = WholeS & S Loop Close InFNum Open OutFName For Output As OutFNum Print #OutFNum, WholeS Close OutFNum -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "JaiJai" wrote in message ... How can I read a mulitple line in a text file and then print it as a single line? eg... she is beautiful output as... she is beautiful -- JaiJai ------------------------------------------------------------------------ JaiJai's Profile: http://www.excelforum.com/member.php...o&userid=19484 View this thread: http://www.excelforum.com/showthread...hreadid=483888 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can Macro read line graphs? | Excel Discussion (Misc queries) | |||
Can Macro read line graphs? | Charts and Charting in Excel | |||
Read only command line switch | Excel Discussion (Misc queries) | |||
Textbox-read text line by line | Excel Programming | |||
read last line of a file | Excel Programming |