Hello,
I have the following VB script that I cobbled together to create an individual text file from each row in an excel, it takes the value from columns A, B & C to create the text file. My issue is that every time I run it, it appends a '?' at the end of the record in the text file. See example below:
Column A Value: <import><node type="email" action="create"><location>Home:Folder1:Email Archive_Volume1:John Doe:John Doe1.pst</location>
Column B Value: <file>\\ftps\d$\email_pst_files\John Doe Archive\pst1.pst\New Listing_ ±114 Acre Commercial Development Site Approved for up to 6.33 Million SF of Retail, Industrial, Warehousing or Manufacturing - Boaz, AL(2).msg
Column "C" Value: </file></node></import>
What I get in the text file: <import><node type="email" action="create"><location>Home:Folder1:Email Archive_Volume1:John Doe:John Doe1.pst</location><file>\\ftps\d$\email_pst_files\John Doe Archive\pst1.pst\New Listing_ ±114 Acre Commercial Development Site Approved for up to 6.33 Million SF of Retail, Industrial, Warehousing or Manufacturing - Boaz, AL(2).msg</file></node></import>?
Here is the VB Code I am using:
Interestingly, if the values from all 3 columns are place into one column, i do not get the question mark, but it truncates the value into the text file if the number of characters exceed 255, which is why I split the data across the three columns.
Sub ExportTextFiles()
Dim i As Long
Dim LastDataRow As String
Dim MyFile As String
Dim fnum
LastDataRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LastDataRow
'The next line uses the contents of column B on the same row to name it
MyFile = "C:\Users\patrick.WINDSORANDJORDA\Documents\david_lau\pst1\" & ActiveSheet.Range("D" & i).Value & ".xml"
fnum = FreeFile()
Open MyFile For Output As fnum
Print #fnum, Format(Range("A" & i)) & Format(Range("B" & i)) & Format(Range("C" & i))
Close fnum
Next i
End Sub
Display More