How do i pull information from one HTA to another?

Posted on 2008-10-07
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("")
   ("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 =
            strY = cInfo.year.value

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

            MgrInfo strMgrSAM, strExpireDate


End Function
Question by:dhalliday
  • 2
  • 2
LVL 65

Accepted Solution

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: ("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") ("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))
   objFSO.DeleteFile strManagerFile, True
   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



Author Comment

ID: 22669858

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 line where it tells me i can't use parentheses when calling a sub.



Author Closing Comment

ID: 31503988
Thanks again for your help
LVL 65

Expert Comment

ID: 22673128
Thanks for the grade.

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

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

just by removing the brackets around the Run argument.



Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at (http://www.experts-ex…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to dynamically set the form action using jQuery.

825 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