?
Solved

How do i pull information from one HTA to another?

Posted on 2008-10-07
4
Medium Priority
?
301 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 1000 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

752 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