title: HTA: Trying to write various input boxes and text areas into a text file and also copy to clipboard
body: <p>first post here, long time reader of the site. I've scoured the Internet as a whole and can't find a solution that works and I've tried many rewrites and can't fix it.</p>
  
  <p>I write HTA files for work. Typically department specific note tools to make their job easier. I have everything working that I need except the copy/paste. I copied the copy/paste section from another tool I wrote and it works, but ignores the \r\n and I've always had issues with that so I'm looking to replace that whole section with something more reliable. So I thought if I could just write to a text file, then copy that text file to the clipboard it would be perfect. Since that would also give them the "Oops, I didn't mean to clear that text" option by just loading up the created text file to see what they hit. I plan to also implement the same "oops" on the clear button, so it will write the file, then clear the input boxes to keep the oops file still there.</p>
  
  <p>To do a quick recap, the Write button works perfect, Clear does too (but needs the write to oops file), and the Copy button needs to be fully rewritten. I'd like to keep it all VBScript if possible since I think my issues thus far are stemming from two code types and my copy/pasting old code into new tools.</p>
  
  <p>One thing to keep in mind is I'm self taught and only make these for work. So don't go super technical on me, I won't understand. If possible please re-write the section(s) needed and let me know why and what's happening in the code so I can grasp the concept and be able to work with it/modify it in the future as I learn and grow.</p>
  
  <p>Code is below:</p>
  
  <pre><code>&lt;hta:application
  icon="#"
  border="thin"
  borderStyle="static"
  caption="yes"
  innerBorder="no"
  maximizeButton="no"
  minimizeButton="yes"
  navigable="no"
  scroll="no"
  scrollFlat="yes"
  singleInstance="yes"
  showInTaskbar="yes"
  windowState="normal"
  contextMenu="no"
  version="1.0"
  &gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;Note Tool&lt;/TITLE&gt;
  
  &lt;style type='text/css'&gt;
  &lt;/style&gt;
  
  &lt;/head&gt; 
  
  &lt;SCRIPT LANGUAGE="VBScript"&gt;
  Function Writer_OnClick()
  
      UserID = (Document.getElementByID("OB1").Value)
      ContactName = (Document.getElementByID("OB2").Value)
      ExternalNotes = (Document.getElementByID("OB3").Value)
      InternalNotes = (Document.getElementByID("OB4").Value)
      CSKBRef = (Document.getElementByID("OB5").Value)
  
      Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("html01.txt",1)
      HTML01 = objFileToRead.ReadAll()
      objFileToRead.Close
      Set objFileToRead = Nothing
  
      Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("html02.txt",1)
      HTML02 = objFileToRead.ReadAll()
      objFileToRead.Close
      Set objFileToRead = Nothing
  
      Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("html03.txt",1)
      HTML03 = objFileToRead.ReadAll()
      objFileToRead.Close
      Set objFileToRead = Nothing
  
      Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("html04.txt",1)
      HTML04 = objFileToRead.ReadAll()
      objFileToRead.Close
      Set objFileToRead = Nothing
  
      Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("html05.txt",1)
      HTML05 = objFileToRead.ReadAll()
      objFileToRead.Close
      Set objFileToRead = Nothing
  
      Set objFileToWrite = CreateObject("Scripting.FileSystemObject").OpenTextFile("poop.html",2,true)
      objFileToWrite.WriteLine(HTML01)
      objFileToWrite.WriteLine(UserID)
      objFileToWrite.WriteLine "&lt;/li&gt;&lt;li&gt;Contacts: "
      objFileToWrite.WriteLine(ContactName)
      objFileToWrite.WriteLine(HTML02)
      objFileToWrite.WriteLine(ExternalNotes)
      objFileToWrite.WriteLine(HTML03)
      objFileToWrite.WriteLine(InternalNotes)
      objFileToWrite.WriteLine(HTML04)
      objFileToWrite.WriteLine(CSKBRef)
      objFileToWrite.WriteLine(HTML05)
      objFileToWrite.Close
      Set objFileToWrite = Nothing
  End Function
  &lt;/SCRIPT&gt;
  
  &lt;script language="VBScript"&gt;
      Sub ClearText
         User.Value = "" 
         Contact.Value = "" 
         ExternalNotes.Value = "" 
         InternalNotes.Value = "" 
         CSKB.Value = "" 
      End Sub
  &lt;/script&gt;
  
  &lt;SCRIPT LANGUAGE="JavaScript"&gt;
      function RestoreWindowSize()
      {
      window.resizeTo(750, 420);
      }
  &lt;/script&gt;
  
  &lt;SCRIPT LANGUAGE="JavaScript"&gt;
  var desc = new Array();
  desc['OB1'] = 'User ID';
  desc['OB2'] = 'Contact Name';
  desc['OB3'] = 'External Notes';
  desc['OB4'] = 'Internal Notes';
  desc['OB5'] = 'CSKB Topic';
  
  function CopyFields(){
      var copytext = '';
      for(var i = 0; i &lt; arguments.length; i++){
          copytext += desc[arguments[i]] + ': ' + document.getElementById(arguments[i]).value + '\r\n';
      }
      var tempstore = document.getElementById(arguments[0]).value;
      document.getElementById(arguments[0]).value = copytext;
      document.getElementById(arguments[0]).focus();
      document.getElementById(arguments[0]).select();
      document.execCommand('Copy');
      document.getElementById(arguments[0]).value = tempstore;
  }
  &lt;/script&gt;
  
  
  &lt;body onload="RestoreWindowSize()"&gt;
  
  User ID: &lt;input type="text" name="User" id="OB1"&gt;&lt;br&gt;
  Contact Name: &lt;input type="text" name="Contact" id="OB2"&gt;&lt;br&gt;
  External Notes: &lt;textarea rows="5" cols="68" type="text" name="ExternalNotes" id="OB3"&gt;&lt;/textarea&gt;&lt;br&gt;
  Internal Notes: &lt;textarea rows="5" cols="68" type="text" name="InternalNotes" id="OB4"&gt;&lt;/textarea&gt;&lt;br&gt;
  KB Reference(s): &lt;input type="text" name="CSKB" id="OB5"&gt;&lt;br&gt;
  
  &lt;br&gt;&lt;br&gt;
  &lt;input type="button" onClick="ClearText" value="Clear Me"&gt;
  &lt;input type="button" name="Copier" value="Copy Me" onClick="CopyFields 'OB1', 'OB2', 'OB3', 'OB4', 'OB5'"&gt;
  &lt;input type="button" name="Writer" value="Write Me"&gt;
  
  
  &lt;/body&gt; 
  &lt;/html&gt; 
  </code></pre>