G
Guest
Hello,
I need to control a separate program from within Access VBA. Specifically,
I need to
1 Open the program
2 Navigate to a form
3 Populate several text boxes
4 “send†the information with an F12
5 Read the returned information and populate a form within Access with the
info
6 Recognize errors in this process
The dreaded sendkeys appears to work OK for 1-4 but how can I get the
information back? I looked into some VB commands like
“redirectstandardoutput†but the VBA compiler chokes on this code example
from (http://www.devx.com/dotnet/Article/7914/0/page/5)
Could I be missing a reference to run this in VBA or does VBA not support
this. The lines with an asterisk create errors before running the code.
The outside program is written in C+ (I think) and it creates a log file but
the log file is a “powerbuilder†(.PBD) file which looks like it has some
type of encryption??
Thanks for any guidance you can provide!
*Dim myProcess As Process = New Process()
Dim s As String
myProcess.StartInfo.FileName = "cmd.exe"
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.RedirectStandardInput = True
myProcess.StartInfo.RedirectStandardOutput = True
myProcess.StartInfo.RedirectStandardError = True
* myProcess.Start()
* Dim sIn As StreamWriter = myProcess.StandardInput
sIn.AutoFlush = True
* Dim sOut As StreamReader = myProcess.StandardOutput
* Dim sErr As StreamReader = myProcess.StandardError
sIn.Write("dir c:\windows\system32\*.com" & _
System.Environment.NewLine)
sIn.Write("exit" & System.Environment.NewLine)
s = sOut.ReadToEnd()
If Not myProcess.HasExited Then
* myProcess.Kill()
End If
* MessageBox.Show("The 'dir' command window was " & _
* closed at: " & myProcess.ExitTime & "." & _
* System.Environment.NewLine & "Exit Code: " & _
* myProcess.ExitCode)
* sIn.Close()
* sOut.Close()
* sErr.Close()
* myProcess.Close()
MessageBox.Show(s)
I need to control a separate program from within Access VBA. Specifically,
I need to
1 Open the program
2 Navigate to a form
3 Populate several text boxes
4 “send†the information with an F12
5 Read the returned information and populate a form within Access with the
info
6 Recognize errors in this process
The dreaded sendkeys appears to work OK for 1-4 but how can I get the
information back? I looked into some VB commands like
“redirectstandardoutput†but the VBA compiler chokes on this code example
from (http://www.devx.com/dotnet/Article/7914/0/page/5)
Could I be missing a reference to run this in VBA or does VBA not support
this. The lines with an asterisk create errors before running the code.
The outside program is written in C+ (I think) and it creates a log file but
the log file is a “powerbuilder†(.PBD) file which looks like it has some
type of encryption??
Thanks for any guidance you can provide!
*Dim myProcess As Process = New Process()
Dim s As String
myProcess.StartInfo.FileName = "cmd.exe"
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.RedirectStandardInput = True
myProcess.StartInfo.RedirectStandardOutput = True
myProcess.StartInfo.RedirectStandardError = True
* myProcess.Start()
* Dim sIn As StreamWriter = myProcess.StandardInput
sIn.AutoFlush = True
* Dim sOut As StreamReader = myProcess.StandardOutput
* Dim sErr As StreamReader = myProcess.StandardError
sIn.Write("dir c:\windows\system32\*.com" & _
System.Environment.NewLine)
sIn.Write("exit" & System.Environment.NewLine)
s = sOut.ReadToEnd()
If Not myProcess.HasExited Then
* myProcess.Kill()
End If
* MessageBox.Show("The 'dir' command window was " & _
* closed at: " & myProcess.ExitTime & "." & _
* System.Environment.NewLine & "Exit Code: " & _
* myProcess.ExitCode)
* sIn.Close()
* sOut.Close()
* sErr.Close()
* myProcess.Close()
MessageBox.Show(s)