title: Copy randomly generated text from IE
body: <p>Currently I am working on vbs that opens a webpage, enters a login, logs in, enters some information, and receives a randomly generated CD Key.</p>
  
  <p>Is there any way I can copy this CD key? using <code>ie.document.getelementbyid</code> I cant find any ID Associated with the CD key, only with the whole text box containing the CD Key.</p>
  
  <p>Is there any way to specify precisely where on the webpage what I want is? Like choose the text I want to copy from the line its on in the website?</p>
  
  <p>The CD key is always random. The only constant is it will be in a cell, and it has hyphens (like any CD Key)</p>
  
  <p>I just need to extract the CD Key so I can store it in a text file etc. like in the example below</p>
  
  <p><img src="https://i.stack.imgur.com/aJptV.png" alt="Example"></p>
  
  <p>Edit:</p>
  
  <p>Code so far:</p>
  
  <pre><code>Set IE = CreateObject("InternetExplorer.Application") 
   IE.Visible = 1    
   IE.navigate "xxxx" 
   Do While (IE.Busy)    
       WScript.Sleep 100    
   Loop    
   Set Helem = IE.document.getElementByID("UserNameTextBox") 
   Helem.Value = "xxxxx"    
   Set Helem = IE.document.getElementByID("PasswordTextBox")
   Helem.Value = "xxxxx"   
   Set Helem = IE.document.getElementByID("Button1")
   Helem.Click
   Do While (IE.Busy)    
       WScript.Sleep 100    
   Loop  
  Set Helem = IE.document.getElementByID("generateECodes_PackageDropdown")
  Helem.Value = "430"
  IE.Document.getElementByID("generateECodes_PackageDropdown").FireEvent ("onChange")
  WScript.Sleep 500
   Do While (IE.Busy)    
       WScript.Sleep 500    
   Loop  
  Set Helem = IE.document.getElementByID("generateECodes_TermDropdown")
  Helem.Value = "5"
  IE.Document.getElementByID("generateECodes_TermDropdown").FireEvent ("onChange")
   Do While (IE.Busy)    
       WScript.Sleep 500    
   Loop  
  Set Helem = IE.document.getElementByID("generateECodes_Languages")
  Helem.Value = "29"
  IE.Document.getElementByID("generateECodes_Languages").FireEvent ("onChange")
   Do While (IE.Busy)    
       WScript.Sleep 500    
   Loop  
  Set Helem = IE.document.getElementByID("generateECodes_StoreNumber")
  Helem.Value = "230"
  IE.Document.getElementByID("generateECodes_StoreNumber").FireEvent ("onChange")
   Do While (IE.Busy)    
       WScript.Sleep 500    
   Loop  
   Set Helem = IE.document.getElementByID("generateECodes_Required")
   Helem.Value = "1" 
   Do While (IE.Busy)    
       WScript.Sleep 500    
   Loop  
   Set Helem = IE.document.getElementByID("generateECodes_Button")
   Helem.Click
   Do While (IE.Busy)    
       WScript.Sleep 500    
   Loop  
     Set Helem = IE.document.getElementByID("generateECodes_Table")
  
  
   Do While (IE.Busy)    
       WScript.Sleep 100    
   Loop  
  
  dim filesys, filetxt, getname, path 
  Set filesys = CreateObject("Scripting.FileSystemObject") 
  Set filetxt = filesys.CreateTextFile("c:\Something.txt", True) 
  path = filesys.GetAbsolutePathName("c:\Something.txt") 
  getname = filesys.GetFileName(path) 
  filetxt.WriteLine("Password: "+Helem) 
  filetxt.WriteLine("Brugernavn: "+Helem) 
  filetxt.Close 
  </code></pre>