Computer Learning Zone CLZ Access Excel Word Windows

It is a miracle that curiosity survives formal education.

-Albert Einstein
 
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   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

 

 

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
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
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2023 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 12/8/2023 12:47:29 AM.