Solved

How do i pull information from one HTA to another?

Posted on 2008-10-07
4
295 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
  • 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
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 modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

685 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