PDA

View Full Version : Solved: Create a .txt file



Rejje
06-10-2011, 02:45 PM
Hi!

Is it possible to make a workbook create a .txt file containing the value of a certain cell?

I would like to make this happen and for the .txt file to be placed in the same folder as the workbook.

Kenneth Hobs
06-10-2011, 06:14 PM
Sub Test()
Dim ff As Integer, sDir1 As String, sFN1 As String

Range("A1").Value = "Hello World!"

sDir1 = ThisWorkbook.Path & "\"
sFN1 = "Test.txt"

ff = FreeFile
Open sDir1 & sFN1 For Output As #ff
Print #ff, Range("A1").Value
Close #ff

Shell "Notepad.exe " & sDir1 & sFN1
End Sub

Rejje
06-11-2011, 01:55 AM
This was exaxtly how I meant.

Thank you Kenneth!

Rejje