Hello!
I'm writing a Macro that writes the contents of the cells in the first column of a worksheet into an already existing .txt file on my desktop. All of that is working fine and dandy until I want to save the .txt file under a new name (See bolded code below). I'm getting an Object Required Error, probably because my syntax is incorrect. Anyone have any helpful corrections?
Thank you!!
Sheets("Blank").Select
Range("A1").Select
Selection.pastespecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Dim r As Integer
Open "Macintosh HD:Users:Name:Desktop:trial.txt" For Output As #1
Sheets("Blank").Activate
ii = Sheets("Blank").Cells(Rows.Count, 1).End(xlUp).Row
For r = 1 To ii
data = Cells(r, 1)
Print #1, data
Next r
ActiveDocument.SaveAs Filename:="NewDocument.txt", _
FileFormat:=wdFormatText
Close
Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you since it's your first post. --6SJ
Bookmarks