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