anyone have experience with reflections integration?

S

statikf

I am attempting to use a terminal program named Reflections to
transfer some data via ftp in to a local directory to use import text
and bring into a table in my database. Reflections automaticaly
generates VBA code from recordable macros, so this should be really
straight forward, but the problem is that when the code is pasted in
to a module in Access it fails to run all of the functions.

The code looks like this I will mark the places the code fails and the
explanations I get throughout the code like this >>>Error(error
message) :


Option Explicit
Dim MyReflectionObject As Object

Sub Login()
' Generated by the Reflection Macro Recorder on 04-02-2007
07:36:51.46.
' Generated by Reflection for ReGIS Graphics 9.0.
Dim Reflection As Object
Dim username As String
Dim password As String

Const NEVER_TIME_OUT = 0

Dim LF As String ' Chr$(rcLF) = Chr$(10) = Control-J
Dim CR As String ' Chr$(rcCR) = Chr$(13) = Control-M
Dim ESC As String ' Chr$(rcESC) = Chr$(27) = Control-[
'>>> Error (previous 3 lines give me a "variable not defined")

LF = Chr$(rcLF)
CR = Chr$(rcCR)
ESC = Chr$(rcESC)

' Create a new instance of Reflection.
Set Reflection = CreateObject("Reflection4.Session")
' Use the statement below instead to attach to an existing
instance of Reflection.
' Set Reflection = GetObject(, "Reflection4.Session")

' Normally the Reflection application will be visible while this
macro is running,
' and will remain open when this macro terminates.
' Delete the following line if you want Reflection to be invisible
and automatically closed.
Reflection.Visible = True

username = "username"
' Password was removed from this macro for security.
' Prompt for (what is assumed to be) a password.
password = Reflection.GetPassword( _
Prompt:="Password:", _
HostUserName:=username)
If password = "" Then Exit Sub

' Do not let Reflection process data communications between API
calls.
Reflection.ProcessDatacomm = False

If Reflection.Connected = False Then
Reflection.ConnectionType = "BEST-NETWORK"
Reflection.ConnectionSettings = "Host bpicsusmfg"
Reflection.ConnectionSettings = "DefaultNetwork TELNET"
End If
If Reflection.Connected = False Then
Reflection.Connect
End If

Reflection.StatusBar = "Waiting for Prompt: login:"
Reflection.WaitForString LF & "login: ", NEVER_TIME_OUT,
rcAllowKeystrokes
'>>> Error (previous line give me a "variable not defined")
Reflection.StatusBar = ""
Reflection.Transmit username & CR

Reflection.StatusBar = "Waiting for Prompt: Password:"
Reflection.WaitForString LF & "Password: ", NEVER_TIME_OUT,
Options:=rcAllowKeystrokes
'>>> Error (previous line give me a "variable not defined")

Reflection.StatusBar = ""
Reflection.Transmit password, Options:=rcDecodePassword
'>>> Error (previous line give me a "variable not defined")
Reflection.Transmit CR

Reflection.StatusBar = "Waiting for Prompt: Enter Your Selection"
Reflection.WaitForString LF & "Enter Your Selection ",
NEVER_TIME_OUT, Options:=rcAllowKeystrokes
'>>> Error (previous line give me a "variable not defined")
Reflection.StatusBar = ""

Reflection.CommitLoginProperties
Reflection.Transmit "6"

' String omitted because it might change:
' Reflection.WaitForString "6", NEVER_TIME_OUT, options:=
rcAllowKeystrokes
Press VtEnter (Simulate pressing the Enter key).
Reflection.TransmitTerminalKey "rcVtEnterKey"
'>>> Error (previous line give me a "variable not defined")

' The following string was not unique:
' Reflection.WaitForString ESC & "[2;64H", NEVER_TIME_OUT,
rcAllowKeystrokes
' Reflection.WaitForString "9H" & ESC & "[2;64H", NEVER_TIME_OUT,
rcAllowKeystrokes

' Resume normal data communications processing.
Reflection.ProcessDatacomm = True
' Recording stopped at 07:37:40.24.
End Sub

Any ideas on why the code will not work would be greatly appreciated.
I dont think that I am missing anything I set up my refrences right
and when all the lines that cause errors are commented out the
application will launch and prompt for a password then hang. Please
help... PS I know this is kind of OT but I think that this may be the
best group to help me out as some of you may have experience with
this.
Thanks agian,
Nate
 
S

storrboy

I would start by suggesting that VBA does not know what rcLF, rcCR and
rcESC are. I think you should use the actual ascii number.

Dim LF As String ' Chr$(rcLF) = Chr$(10) = Control-J
Dim CR As String ' Chr$(rcCR) = Chr$(13) = Control-M
Dim ESC As String ' Chr$(rcESC) = Chr$(27) = Control-[

LF = Chr$(10)
CR = Chr$(13)
ESC = Chr$(27)
 
S

statikf

Thanks that did help with the errors that are created by defining the
variables but not those caused by rcAllowKeystrokes. Is there
something that I'm missing as far as a declaration? This code was auto
generated by the Reflections application and I am following the
documentation to the best of my ability to try to implement it. From
the code examples I have looked at, and the documentation I have read
there is not a need to do anything else in order to have these VBA
macros work other than set the refrences and paste the code.
 
S

statikf

I managed to get around the problem with the rcAllowKeystrokes but The
line

Reflection.Transmit password, options:=rcDecodePassword

is still causing an error saying variable not defined. Just so that
it's clear how I dealt with the previous problem I replaced the lines
like

Reflection.WaitForString LF & "login: ", NEVER_TIME_OUT,
rcAllowKeystrokes
with
Reflection.WaitForString LF & "login: ", NEVER_TIME_OUT, 0

they are working correctly, but when I replace the rcDecodePassword
with 0 the password is being sent still encoded (I can see this by
piping it through netcat to look at the raw data) I am going to try
using the password in clear text this should be a non issue in the
context that I am using this.
Thanks agian for the help will let you know how it goes.

Nate
 
S

storrboy

I'm not familiar with the reference you are using (should have
mentioned that I suppose), but the error messages indicate that VB
does not know the value of the variable(s) that get pointed out. Best
thing to do is find out what the values are supposed to be from the
creator(s) of the component and make sure they are Dim'd properly as
vars or constants. You can try guessing and see what works, but that
may take you a while.
 
N

njack217

thats ok the work around using a clear text password did the job. I
built a form that hides it as it's entered, only difference is that
it's never encrypted or scrambled (or whatever the getpassword
function does and now the whole thing is working. Thanks for your help
with the variable issues though that actually helped alot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top