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
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
CODE
What string row, column, length???
THAT could be one reason.
Skip,
Just traded in my old subtlety...
for a NUANCE!
RE: Can't get EBM macro to work from Extra sessions to Word 2007 Doc
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
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
Skip,
Just traded in my old subtlety...
for a NUANCE!
RE: Can't get EBM macro to work from Extra sessions to Word 2007 Doc
RE: Can't get EBM macro to work from Extra sessions to Word 2007 Doc
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
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