I am having some trouble with the code below. I have a list with two
columns like the following:
ABC 12345
XYZ 45678
I used the following code to export each row into a text file, such
that the name of the txt file was the name of the first column, ie
ABC.txt, and the single entry within it was the second column, ie
12345. The code I use is below:
Sub Example()
Const kPath As String = "C:\users\adrian\documents\notes"
Dim oCell As Range
Dim iFile As Integer
For Each oCell In Range("A1:A200")
iFile = FreeFile
Open kPath & oCell.Value & ".txt" For Output As #iFile
Print #iFile, oCell.Offset(0, 1).Value
Close #iFile
Next oCell
End Sub
This works great in earlier versions of Excel, but in Excel 2007,
nothing is printed to a file, and no errors in the script are
reported. I have checked my 'trusted locations' to ensure the
directory above is in the list.
Can anyone provide any pointers on what Excel 2007 needs to make this
work?