Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - saving strings to a text file
Is there any Excel VBA code to save strings to a text file?
|
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - saving strings to a text file
Look for the Open statement, whose See Also link should lead you to Close,
Print, Write, and even Input and Read. -- --Andy Smith "JohnJ" wrote: Is there any Excel VBA code to save strings to a text file? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - saving strings to a text file
Try code like the following to get started:
Dim FName As String Dim FNum As Integer Dim S As String FName = "C:\Test\TestFile.txt" FNum = FreeFile S = "Write This" Open FName For Output Access Write As #FNum Print #FNum, S Close #FNum -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "JohnJ" wrote in message ... Is there any Excel VBA code to save strings to a text file? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - saving strings to a text file
I should have noted that if you open the file for Output, the existing
contents of the file are destroyed. To keep the existing content, open for Append: Open FName For Append Access Write As #FNum This will cause the data to be written at the end of the existing contents. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Chip Pearson" wrote in message ... Try code like the following to get started: Dim FName As String Dim FNum As Integer Dim S As String FName = "C:\Test\TestFile.txt" FNum = FreeFile S = "Write This" Open FName For Output Access Write As #FNum Print #FNum, S Close #FNum -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "JohnJ" wrote in message ... Is there any Excel VBA code to save strings to a text file? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
find and replace numeric strings in larger text strings | Excel Worksheet Functions | |||
Saving multi-tab excel file created from comma delimited text file | Excel Programming | |||
Clean up strings before creating a text file | Excel Programming | |||
Writing strings to a text file ? | Excel Programming | |||
import text-file - strings contain cr-lf | Excel Programming |