I'm using the following code to gather a range of cells in Excel before writing them to a text file. The thing I need to do now is to squeeze a couple of extra fields of text in between a couple of these cells in this range. I was thinking of just adding the text to a cell way off out there in the spreadsheet but that would mean that someone may someday erase it not knowing what it is. I'd like to slide these additional fields into the range between cells F12:F17. Is there a way to do this or should I just let the file finish writing and then reopen the file, read the items in sequentially and then slide the new items in before re-writing the text file?
Or perhaps better, now that I re-examine it, The string c01 could be manipulated after assembly, but before writing the string to a text file. Trouble is shows up in the watch window as a string with a length of 36. It will never always be the same based on the data read into it, so I would need a way to parse if on the vbCrLf's in it.
Or perhaps better, now that I re-examine it, The string c01 could be manipulated after assembly, but before writing the string to a text file. Trouble is shows up in the watch window as a string with a length of 36. It will never always be the same based on the data read into it, so I would need a way to parse if on the vbCrLf's in it.
Code:
Dim objWriter As New StreamWriter("C:\TEMP\MyTextFile.txt")
Dim c01 As String = ""
c01 = vExcelSheet1.Range("D5").Value
For Each cl In vExcelSheet1.Range("D6,G8,F12:F17,F19,F22:F25,F28,F30:F31,F33:F37,F39:F41,F43,I15")
c01 = c01 & vbCrLf & Trim(cl.Value)
Next
objWriter.WriteLine(c01)
.
.
.