Computer Learning Zone CLZ Access Excel Word Windows

They cannot stop me. I will get my education, if it is in the home, school, or anyplace.

-Malala Yousafzai
 
Home   Courses   Seminars   Templates   Help   TechHelp   Forums   Contact   Join   Order   Logon  
 
Tips & Tricks

New Tips Added Weekly!
Click here to get on our Mailing List

   
 
HTA

Expert - Write File

How to write to a File

Add a TextArea to your HTA.

	<textarea name="TextFile" id="TextFile" rows="20" cols="50">
	</textarea>
	

Add a button to write to the file.

	<input type="button" value="Submit" onclick="Submitarea">
    

Then add some code.

	Const ForWriting = 2
	
	Dim objFSO, objFile, strFileName
	strFileName = "textfile.txt"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
	
	Set objFile = objFSO.OpenTextFile(strFileName, 2, true)
	Set objShell = CreateObject("WScript.Shell")
	
	Sub Submitarea
		sTxtarea = TextFile.Value
		oFIle.Write sTxtarea & vbCRLF
		MsgBox "Your text has been added to " & strFileName, 64, "Textarea Input"
	End Sub
	

It would then be handy to open that File. Add another button to do this.

	<input type="button" value="Open" onclick="OpenTxtArea">
	
	Sub OpenTxtArea
		ShellRun = objShell.Run ("%comspec% /c Start Notepad " & strFileName, 0, 1)
    End Sub 
	

WriteFile HTA


Sample Files
.hta


Previous Lesson: Expert Level 3 | Next Lesson:

 

Alex Hedley (Avatar) By: Alex Hedley


Click here to sign up for more FREE tips

 

 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn