Solved

How do i pull information from one HTA to another?

Posted on 2008-10-07
4
298 Views
Last Modified: 2013-11-05
I am creating a set of HTA files that will be part of a user creation process.

The current code I have will pull up a second window for the manager information to be entered using this when the box is checked:

Public Function contStatus_OnClick()
            
            Set objShell = CreateObject("Wscript.shell")
            objShell.run ("mshta.exe \\testenv\User_Creation\Information\ManInfo.hta")

End Function


I need to pull the variables from that second window into the existing (parent) hta for mass input into an excel doc.

Here is the base function for the second HTA box:

Public Function contInfo_OnClick()

      if cInfo.manager_fname.value = "" then
            msgbox("Please re-enter the manager information")
            contInfo_OnClick = False
      elseif cInfo.manager_lname.value = "" then
            msgbox("Please re-enter the manager information")
            contInfo_OnClick = False
            
      End if
                  
            strMgrFN = cInfo.manager_fname.value
            strMgrLN = cInfo.manager_lname.value
            strMgrSAM = strMgrFN & "." & strMgrLN
      
            strM = cInfo.month.value
            strD = cInfo.date.value
            strY = cInfo.year.value

            strExpireDate = strM & "/" & strD & "/" & strY

            MgrInfo strMgrSAM, strExpireDate

window.close()

End Function
0
Comment
Question by:dhalliday
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 250 total points
ID: 22663471
Hi dhalliday,

The two HTA's are unaware of each other, and so cannot directly pass information.  You're best best is to run the second HTA using:

objShell.run ("mshta.exe \\testenv\User_Creation\Information\ManInfo.hta", 1, True)

so that the code in the first HTA waits for the second HTA to close.  Then, the idea behind that is that the second HTA writes the data to a text file, which the first HTA then picks up once the code has resumed (after the second has been closed).

So, the code in the first one would be something like:

'=================
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1
Set objShell = CreateObject("WScript.Shell")
objShell.run ("mshta.exe \\testenv\User_Creation\Information\ManInfo.hta", 1, True)
strManagerFile = "ManagerInfo.txt"
If objFSO.FileExists(strManagerFile) = True Then
   Set objFile = objFSO.OpenTextFile(strManagerFile, intForReading, False)
   While Not objFile.AtEndOfStream
      strLine = objFile.ReadLine
      If Left(strLine, 12) = "First Name: " Then txt_mgrfirst.Value = Trim(Mid(strLine, 12))
      If Left(strLine, 11) = "Last Name: " Then txt_mgrlast.Value = Trim(Mid(strLine, 11))
   Wend
   objFile.Close
   objFSO.DeleteFile strManagerFile, True
Else
   MsgBox "Unable to find " & strManagerFile
End If
'=================

and the code in the second would be something like:

'=================
Set objFSO = CreateObject("Scripting.FileSystemObject")
strManagerFile = "ManagerInfo.txt"
Set objFile = objFSO.CreateTextFile(strManagerFile, True)
objFile.Write "First Name: " & txt_mgrfirst.Value & vbCrLf
objFile.Write "Last Name: " & txt_mgrlast.Value
objFile.Close
window.Close
'=================


Regards,

Rob.
0
 

Author Comment

by:dhalliday
ID: 22669858
Rob,

First, thank you for the input.  I am still in the learning phase with VBScript and am greatful for the assistance.

When i try to implement this i am running into a error on the objShell.run line where it tells me i can't use parentheses when calling a sub.


Thanks,

Dhalliday
0
 

Author Closing Comment

by:dhalliday
ID: 31503988
Thanks again for your help
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22673128
Thanks for the grade.

For the above error, just change this:
objShell.run ("mshta.exe \\testenv\User_Creation\Information\ManInfo.hta", 1, True)

to this
objShell.run "mshta.exe \\testenv\User_Creation\Information\ManInfo.hta", 1, True

just by removing the brackets around the Run argument.

Regards,

Rob.
0

Featured Post

Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question