-
Jun 7th, 2006, 05:31 PM
#1
Thread Starter
Member
[RESOLVED] Creating Text Files From Excel's VBA
So, (with some help, thx Si) I've successfully used the code below to create Text files from Excel's VBA. I have a new problem though.
How do I pass more than one line of text to the file?
Ideally I'ld like to be able to pass an ENTER keystroke(within "myString") and continue sText (myString) on a new line.
VB Code:
Dim sFile As String
Dim sText As String
Dim iFileNum As Integer
sFile = "C:\(path)\Textfile.txt"
sText = "myString"
iFileNum = FreeFile
Open sFile For Output As iFileNum
Print #iFileNum, sText
Close #iFileNum
Last edited by RobDog888; Jun 7th, 2006 at 05:33 PM.
Reason: Fixed vbcode tags
-
Jun 7th, 2006, 05:34 PM
#2
Re: Creating Text Files From Excel's VBA
Each print statement will end with a new line.
VB Code:
Open sFile For Output As iFileNum
Print #iFileNum, sText
Print #iFileNum, "More text on next line"
Print #iFileNum, "Etc."
Close #iFileNum
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jun 7th, 2006, 06:45 PM
#3
Thread Starter
Member
Re: [RESOLVED] Creating Text Files From Excel's VBA
Wow That was fast! Thanks for the help. Worked great.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|