×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Can't get EBM macro to work from Extra sessions to Word 2007 Doc

Can't get EBM macro to work from Extra sessions to Word 2007 Doc

Can't get EBM macro to work from Extra sessions to Word 2007 Doc

(OP)
I'm trying to automate redundant letters in Word 2007. I made a macro to do just that, but my currents skills cannot find where my error is. Can someone please inform me of my mistake(s)? Basically, I want to copy from various screens of 'Extra' to the same document for each customer; while also having the Word doc stay Active (not closing and reopening each time). I've put 'labels' in the Word doc and have referenced them correctly. Extra, however, doesn't like my macro.

Thank you.

Declare Function MyFunction()

Sub Main

call MyFunction()

Function MyFunction()
Dim wrd As Object
Dim Session As Object
Dim System As Object
Dim MyScreen as Object

Dim CustomerName as String
Dim CustomerAddress as String
Dim CustomerAddress2 as String
Dim LienHolderName as String
Dim LienHolderAddress as String
Dim LienHolderAddress2 as String
Dim AccountNumber as String
Dim PayoffAmount as String
Dim VinNumber as String
Dim LoanNumber as String


Set System = CreateObject("EXTRA.System")
Set Session = System.ActiveSession
Sess0.Screen.Sendkeys("va")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime
Set MyScreen = Session.Screen
Set the default wait timeout value
g_HostSettleTime = 1000 ' milliseconds

CustomerName =MyScreen.GetString(1,40,30)
StreetAddress =MyScreen.GetString(13,16,20)
StreetAddress2 =MyScreen.GetString(13,37,25)

Sess0.Screen.Sendkeys("<Esc>[d~<Esc>[d~ud<Ctrl+V>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

LienHolderName =MyScreen.GetString(6,53,40)
LienHolderAddress =MyScreen.GetString(8,57,40)
LienHolderAddress2 =MyScreen.GetString(9,53,20)
AccountNumber =MyScreen.GetString(6,9,23)
PayoffAmount =MyScreen.GetString(6,34,8)
VinNumber =MyScreen.GetString(13,15,18)

Sess0.Screen.Sendkeys("<Esc>[V~<Esc>[V~<Esc>[V~<Esc>[V~")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

LoanNumber =MyScreen.GetString


Set wrd = CreateObject("Word.application")
wrd.Documents.Open "C:\Documents and Settings\e576009\Desktop\Refi_macro_letter.docm"
wrd.Visible = True

wrd.ActiveDocument.CustomerName.Caption= (CustomerName)
wrd.ActiveDocument.CustomerAddress.Caption= (CustomerAddress)
wrd.ActiveDocument.CustomerAddress2.Caption= (CustomerAddress2)
wrd.ActiveDocument.LienHolderName.Caption= (LienHolderName)
wrd.ActiveDocument.LienHolderAddress.Caption= (LienHolderAddress)
wrd.ActiveDocument.LienHolderAddress2.Caption= (LienHolderAddress2)
wrd.ActiveDocument.AccountNumber.Caption= (AccountNumber)
wrd.ActiveDocument.PayoffAmount.Caption= (PayoffAmount)
wrd.ActiveDocument.VinNumber.Caption= (VinNumber)
wrd.ActiveDocument.LoanNumber.Caption= (LoanNumber)


Set wrd = Nothing

End Function

Sub End

RE: Can't get EBM macro to work from Extra sessions to Word 2007 Doc

Hi,

CODE

LoanNumber =MyScreen.GetString 

What string row, column, length???

THAT could be one reason.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Can't get EBM macro to work from Extra sessions to Word 2007 Doc

(OP)
Thanks!

I fixed that portion, but it seems to not initiate from the start. Is my organization incorrect?

RE: Can't get EBM macro to work from Extra sessions to Word 2007 Doc

the Extra VB Editor is .... well it's poor!

I almost NEVER code in Extra! I do nearly all my coding in Excel VBA, as I'd much rather drive a cadillac than a yugo.

Pasting your code into a decent editor, IMMEDIATELY highlighted these two issues.

Anyhow...

CODE

Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Set MyScreen = Session.Screen
'   Set the default wait timeout value 

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Can't get EBM macro to work from Extra sessions to Word 2007 Doc

(OP)
Could someone please tell me why my macro fails to execute?

RE: Can't get EBM macro to work from Extra sessions to Word 2007 Doc

jaynlola,

i'm not able to compile your code. it highlights errors immediately. One error that catches my eye is on your last line,
"sub end". you have your function nested within your main code. check out the Help files for an example.

did you try recording a macro first, so that you get the body of macro correct?

RE: Can't get EBM macro to work from Extra sessions to Word 2007 Doc

(OP)
Here's the code if I was to 'record' it live; although I need it to copy certain coordinates and paste into the Word doc (as posted above):


Code is as follows -
'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
' Session Document: "C:\Program Files\Extra Sessions\RCO\Retail-Direct.edp"
' Date: Wednesday, August 07, 2013 12:02:45
' User: e576009
'--------------------------------------------------------------------------------

' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$

Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 1000 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

' This section of code contains the recorded events
Sess0.Screen.Copy
Sess0.Screen.Copy
Sess0.Screen.Copy
Sess0.Screen.Copy
Sess0.Screen.Copy
Sess0.Screen.Copy
Sess0.Screen.Copy
Sess0.Screen.Copy
Sess0.Screen.Copy
Sess0.Screen.Copy
Sess0.Screen.Copy
Sess0.Screen.Copy
Sess0.Screen.Copy
Sess0.Screen.Sendkeys("va<Esc>[d~<Esc>[d~ud<Ctrl+V><Esc>[V~<Esc>[V~<Esc>[V~<Esc>[V~")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

System.TimeoutValue = OldSystemTimeout
End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close