ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create and write a simple text file in Excel/VBA (https://www.excelbanter.com/excel-programming/294880-create-write-simple-text-file-excel-vba.html)

Thomas Wieser

Create and write a simple text file in Excel/VBA
 
Hi,

what is the easiest way to create a new text file, write one string into
the file and close it afterwards?


Regards, Thomas

Frank Kabel

Create and write a simple text file in Excel/VBA
 
Hi Thomas
have a look at the Write method in the VBA help (included an example
for this)

--
Regards
Frank Kabel
Frankfurt, Germany


Thomas Wieser wrote:
Hi,

what is the easiest way to create a new text file, write one string
into the file and close it afterwards?


Regards, Thomas



JWolf

Create and write a simple text file in Excel/VBA
 
Dim F1 As Integer
F1 = FreeFile
Open "fullpathname\filename.txt" For Output As F1
Print #F1, "Test line" 'Prints: Test Line
Print #F1, yourvariable 'Prints: the value of your variable
Print #F1, "The vaue of yourvariable is: " & yourvariable 'Prints: the
concatation of "quoted" and yourvariable
Close #F1
F1 = 0



Thomas Wieser wrote:

Hi,

what is the easiest way to create a new text file, write one string into
the file and close it afterwards?


Regards, Thomas


Bob Phillips[_6_]

Create and write a simple text file in Excel/VBA
 
Hi Thomas,

From Help

FileNumber = FreeFile
Open "C:\My Documents\TEST10" For Output As #FileNumber
Write #FileNumber, "This is a sample."
Close #FileNumber

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Thomas Wieser" <wernze.nospam@gmx_net wrote in message
y.telekom.at...
Hi,

what is the easiest way to create a new text file, write one string into
the file and close it afterwards?


Regards, Thomas




Thomas Wieser

Create and write a simple text file in Excel/VBA
 
Hi to all,

thanks a lot!


Regards, Thomas


All times are GMT +1. The time now is 07:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com