×
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!
  • Students Click Here

*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

Jobs

Unable to close out my code

Unable to close out my code

Unable to close out my code

(OP)
Hello, A few weeks back I received some great assistance from Remy here. Since then I've been playing with my code to expand on my needs but have hit another wall. The error appears to be with the End Sub. I believe it has to do with my if statements not being closed properly but I am unable to figure out the solution. Please assist!


Code below:

'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
' Session Document: "CPI.edp"
' Date: Friday, May 16, 2014 13:41:10
' User: krwrigh
'--------------------------------------------------------------------------------

' 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 = 200 ' 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


'button group/icon group/default group


'Buttons Value
'OK only 0
'OK, Cancel 1
'Abort, Retry, Ignore 2
'Yes, No, Cancel 3
'Yes, No 4
'Retry, Cancel 5

'Icons Value
'Critical Message (Stop sign) 16
'Warning Query (Question mark ) 32
'Warning Message (Exclamation) 48
'Information Message (lower-case i) 64

'this sets the default button
'Button Defaults Value
'First button 0
'Second button 256
'Third button 512


'Value Button Pressed
'1 OK
'2 Cancel
'3 Abort
'4 Retry
'5 Ignore
'6 Yes
'7 No



msgtex = "Is this an inbound call?"
answer1 = MsgBox(msgtex, 4 + 48 + 512, "Compliance Tool")

If answer1 = "6" Then

msgtex = "Are you speaking to a third party"
answer2 = MsgBox(msgtex, 4 + 32 + 256, "Compliance Tool")


if answer2 = "6" Then
Sess0.Screen.Sendkeys("<Home>mem1<Enter>")
MsgBox"Verify all A3P/Attorney contacts in MEM1"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>saf1<Enter>")
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"Verify the cease and desist code"
Sess0.Screen.Sendkeys("<Home>dlq1<Enter>")
Sess0.Screen.Sendkeys("<Home><Tab><Tab>mort<Enter>")
MsgBox"Verify customer name, property address, mailing address, and last four of social security number. Also look for cease and desist banner as well"
msgbox"Review mancode to read appropriate disclaimer and recording script"
Sess0.Screen.Sendkeys("<Home>dlq8<Enter>")
MsgBox"Verify all contact numbers on the account"
Sess0.Screen.Sendkeys("<Home>for1<Enter>")

msgtex = "Is the foreclosure active?"
answer3 = MsgBox(msgtex, 4 + 48 + 512, "Foreclosure Status")

If answer3 = "6" Then
MsgBox"Verfiy foreclosure status, click okay to continue"
Sess0.Screen.Sendkeys("<Home>for3<Enter>")
MsgBox"Review for U20, click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")

Else
If answer3 = "7" Then
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmt3<Enter>")
MsgBox"Review for a populated L14. If blank, solicit payment per hierarchy"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")

End if

Else
if answer2 = "7" Then
Sess0.Screen.Sendkeys("<Home>dlq1<Enter>")
Sess0.Screen.Sendkeys("<Home><Tab><Tab>mort<Enter>")
MsgBox"Verify customer name, property address, mailing address, and last four of social security number. Also look for cease and desist banner as well"
Sess0.Screen.Sendkeys("<Home>mem1<Enter>")
MsgBox"Verify all A3P/Attorney contacts in MEM1"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>saf1<Enter>")
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"Verify the cease and desist code"
Sess0.Screen.Sendkeys("<Home>dlq1<Enter>")
Sess0.Screen.Sendkeys("<Home><Tab><Tab>mort<Enter>")
msgbox"Review mancode to read appropriate disclaimer and recording script"
Sess0.Screen.Sendkeys("<Home>dlq8<Enter>")
MsgBox"Verify all contact numbers on the account"
Sess0.Screen.Sendkeys("<Home>for1<Enter>")


msgtex = "Is the foreclosure active?"
answer3 = MsgBox(msgtex, 4 + 48 + 512, "Foreclosure Status")

If answer3 = "6" Then
MsgBox"Verfiy foreclosure status, click okay to continue"
Sess0.Screen.Sendkeys("<Home>for3<Enter>")
MsgBox"Review for U20, click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")

Else
If answer3 = "7" Then
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmt3<Enter>")
MsgBox"Review for a populated L14. If blank, solicit payment per hierarchy"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")

End if

Else

If answer1 = "7" Then

msgtex = "Are you speaking to a third party"
answer5 = MsgBox(msgtex, 4 + 48 + 256, "Compliance Tool")


if answer5 = "6" Then
Sess0.Screen.Sendkeys("<Home>mem1<Enter>")
MsgBox"Verify all A3P/Attorney contacts in MEM1"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>saf1<Enter>")
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"Verify the cease and desist code"
Sess0.Screen.Sendkeys("<Home>dlq1<Enter>")
Sess0.Screen.Sendkeys("<Home><Tab><Tab>mort<Enter>")
MsgBox"Verify customer name, property address. Also look for cease and desist banner as well"
msgbox"Review mancode to read appropriate disclaimer and recording script"
Sess0.Screen.Sendkeys("<Home>dlq8<Enter>")
MsgBox"Verify all contact numbers on the account"
Sess0.Screen.Sendkeys("<Home>for1<Enter>")

msgtex = "Is the foreclosure active?"
answer6 = MsgBox(msgtex, 4 + 48 + 256, "Foreclosure Status")

If answer6 = "6" Then
MsgBox"Verfiy foreclosure status, click okay to continue"
Sess0.Screen.Sendkeys("<Home>for3<Enter>")
MsgBox"Review for U20, click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")

Else
If answer6 = "7" Then
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmt3<Enter>")
MsgBox"Review for a populated L14. If blank, solicit payment per hierarchy"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")



Else
if answer5 = "7" Then
Sess0.Screen.Sendkeys("<Home>dlq1<Enter>")
Sess0.Screen.Sendkeys("<Home><Tab><Tab>mort<Enter>")
MsgBox"Verify customer name, property address. Also look for cease and desist banner as well"
Sess0.Screen.Sendkeys("<Home>mem1<Enter>")
MsgBox"Verify all A3P/Attorney contacts in MEM1"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>saf1<Enter>")
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"Verify the cease and desist code"
Sess0.Screen.Sendkeys("<Home>dlq1<Enter>")
Sess0.Screen.Sendkeys("<Home><Tab><Tab>mort<Enter>")
msgbox"Review mancode to read appropriate disclaimer and recording script"
Sess0.Screen.Sendkeys("<Home>dlq8<Enter>")
MsgBox"Verify all contact numbers on the account"
Sess0.Screen.Sendkeys("<Home>for1<Enter>")

msgtex = "Is the foreclosure active?"
answer7 = MsgBox(msgtex, 4 + 48 + 256, "Foreclosure Status")

If answer7 = "6" Then
MsgBox"Verfiy foreclosure status, click okay to continue"
Sess0.Screen.Sendkeys("<Home>for3<Enter>")
MsgBox"Review for U20, click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")

Else
If answer7 = "7" Then
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmt3<Enter>")
MsgBox"Review for a populated L14. If blank, solicit payment per hierarchy"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")






System.TimeoutValue = OldSystemTimeout

End Sub

RE: Unable to close out my code

CODE

If expression Then

Else

End If 

Where are your End Ifs???

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Unable to close out my code

(OP)
Here is the code with the End Ifs where I thought they should rest, but I haven't quite mastered nesting with this code. Thank you for your help!

msgtex = "Is this an inbound call?"
answer1 = MsgBox(msgtex, 4 + 48 + 512, "Compliance Tool")

If answer1 = "6" Then

msgtex = "Are you speaking to a third party"
answer2 = MsgBox(msgtex, 4 + 32 + 256, "Compliance Tool")


if answer2 = "6" Then
Sess0.Screen.Sendkeys("<Home>mem1<Enter>")
MsgBox"Verify all A3P/Attorney contacts in MEM1"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>saf1<Enter>")
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"Verify the cease and desist code"
Sess0.Screen.Sendkeys("<Home>dlq1<Enter>")
Sess0.Screen.Sendkeys("<Home><Tab><Tab>mort<Enter>")
MsgBox"Verify customer name, property address, mailing address, and last four of social security number. Also look for cease and desist banner as well"
msgbox"Review mancode to read appropriate disclaimer and recording script"
Sess0.Screen.Sendkeys("<Home>dlq8<Enter>")
MsgBox"Verify all contact numbers on the account"
Sess0.Screen.Sendkeys("<Home>for1<Enter>")

msgtex = "Is the foreclosure active?"
answer3 = MsgBox(msgtex, 4 + 48 + 512, "Foreclosure Status")

If answer3 = "6" Then
MsgBox"Verfiy foreclosure status, click okay to continue"
Sess0.Screen.Sendkeys("<Home>for3<Enter>")
MsgBox"Review for U20, click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")

Else
If answer3 = "7" Then
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmt3<Enter>")
MsgBox"Review for a populated L14. If blank, solicit payment per hierarchy"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")


End if
End if

Else
if answer2 = "7" Then
Sess0.Screen.Sendkeys("<Home>dlq1<Enter>")
Sess0.Screen.Sendkeys("<Home><Tab><Tab>mort<Enter>")
MsgBox"Verify customer name, property address, mailing address, and last four of social security number. Also look for cease and desist banner as well"
Sess0.Screen.Sendkeys("<Home>mem1<Enter>")
MsgBox"Verify all A3P/Attorney contacts in MEM1"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>saf1<Enter>")
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"Verify the cease and desist code"
Sess0.Screen.Sendkeys("<Home>dlq1<Enter>")
Sess0.Screen.Sendkeys("<Home><Tab><Tab>mort<Enter>")
msgbox"Review mancode to read appropriate disclaimer and recording script"
Sess0.Screen.Sendkeys("<Home>dlq8<Enter>")
MsgBox"Verify all contact numbers on the account"
Sess0.Screen.Sendkeys("<Home>for1<Enter>")



msgtex = "Is the foreclosure active?"
answer3 = MsgBox(msgtex, 4 + 48 + 512, "Foreclosure Status")

If answer3 = "6" Then
MsgBox"Verfiy foreclosure status, click okay to continue"
Sess0.Screen.Sendkeys("<Home>for3<Enter>")
MsgBox"Review for U20, click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")

Else
If answer3 = "7" Then
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmt3<Enter>")
MsgBox"Review for a populated L14. If blank, solicit payment per hierarchy"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")

End if
End if


Else

If answer1 = "7" Then


msgtex = "Are you speaking to a third party"
answer5 = MsgBox(msgtex, 4 + 48 + 256, "Compliance Tool")


if answer5 = "6" Then
Sess0.Screen.Sendkeys("<Home>mem1<Enter>")
MsgBox"Verify all A3P/Attorney contacts in MEM1"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>saf1<Enter>")
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"Verify the cease and desist code"
Sess0.Screen.Sendkeys("<Home>dlq1<Enter>")
Sess0.Screen.Sendkeys("<Home><Tab><Tab>mort<Enter>")
MsgBox"Verify customer name, property address. Also look for cease and desist banner as well"
msgbox"Review mancode to read appropriate disclaimer and recording script"
Sess0.Screen.Sendkeys("<Home>dlq8<Enter>")
MsgBox"Verify all contact numbers on the account"
Sess0.Screen.Sendkeys("<Home>for1<Enter>")

msgtex = "Is the foreclosure active?"
answer6 = MsgBox(msgtex, 4 + 48 + 256, "Foreclosure Status")

If answer6 = "6" Then
MsgBox"Verfiy foreclosure status, click okay to continue"
Sess0.Screen.Sendkeys("<Home>for3<Enter>")
MsgBox"Review for U20, click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")

Else
If answer6 = "7" Then
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmt3<Enter>")
MsgBox"Review for a populated L14. If blank, solicit payment per hierarchy"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")

End if
End if

Else
if answer5 = "7" Then
Sess0.Screen.Sendkeys("<Home>dlq1<Enter>")
Sess0.Screen.Sendkeys("<Home><Tab><Tab>mort<Enter>")
MsgBox"Verify customer name, property address. Also look for cease and desist banner as well"
Sess0.Screen.Sendkeys("<Home>mem1<Enter>")
MsgBox"Verify all A3P/Attorney contacts in MEM1"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>saf1<Enter>")
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"Verify the cease and desist code"
Sess0.Screen.Sendkeys("<Home>dlq1<Enter>")
Sess0.Screen.Sendkeys("<Home><Tab><Tab>mort<Enter>")
msgbox"Review mancode to read appropriate disclaimer and recording script"
Sess0.Screen.Sendkeys("<Home>dlq8<Enter>")
MsgBox"Verify all contact numbers on the account"
Sess0.Screen.Sendkeys("<Home>for1<Enter>")



msgtex = "Is the foreclosure active?"
answer7 = MsgBox(msgtex, 4 + 48 + 256, "Foreclosure Status")

If answer7 = "6" Then
MsgBox"Verfiy foreclosure status, click okay to continue"
Sess0.Screen.Sendkeys("<Home>for3<Enter>")
MsgBox"Review for U20, click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")

Else
If answer7 = "7" Then
Sess0.Screen.Sendkeys("<Home>lmt1<Enter>")
MsgBox"Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
Sess0.Screen.Sendkeys("<Home>lmt3<Enter>")
MsgBox"Review for a populated L14. If blank, solicit payment per hierarchy"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Pf8>")
MsgBox"click okay to continue"
Sess0.Screen.Sendkeys("<Home>lmtn<Enter>")


End if
End if


System.TimeoutValue = OldSystemTimeout

End Sub

RE: Unable to close out my code

hi,
the key is for every If, there is an End If.

you should re-write your code, one End If at a time while inserting Else.

use the indents to help you view the beginning of the If and the end of the End if

CODE

Sub main()
    If answer = 6 Then
    
        If answer = 7 Then
        
        Else
            If answer = 8 Then
            
            End If
        
        End If
    
    Else
        If answer = 7 Then
            If answer = 9 Then
            
            End If
        End If
    End If
End Sub 

if you paste your code into a VBA module, it may be easier.

also, the logic in the code is

RE: Unable to close out my code

CODE

Sub main()
    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 = 200 ' 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)
    msgtex = "Is this an inbound call?"
    answer1 = MsgBox(msgtex, 4 + 48 + 512, "Compliance Tool")

    If answer1 = "6" Then
    
        msgtex = "Are you speaking to a third party"
        answer2 = MsgBox(msgtex, 4 + 32 + 256, "Compliance Tool")
    
        If answer2 = "6" Then
            Sess0.Screen.SendKeys ("<Home>mem1<Enter>")
            MsgBox "Verify all A3P/Attorney contacts in MEM1"
            Sess0.Screen.SendKeys ("<Pf8>")
            MsgBox "click okay to continue"
            Sess0.Screen.SendKeys ("<Pf8>")
            MsgBox "click okay to continue"
            Sess0.Screen.SendKeys ("<Pf8>")
            MsgBox "click okay to continue"
            Sess0.Screen.SendKeys ("<Home>saf1<Enter>")
            Sess0.Screen.SendKeys ("<Pf8>")
            MsgBox "Verify the cease and desist code"
            Sess0.Screen.SendKeys ("<Home>dlq1<Enter>")
            Sess0.Screen.SendKeys ("<Home><Tab><Tab>mort<Enter>")
            MsgBox "Verify customer name, property address, mailing address, and last four of social security number. Also look for cease and desist banner as well"
            MsgBox "Review mancode to read appropriate disclaimer and recording script"
            Sess0.Screen.SendKeys ("<Home>dlq8<Enter>")
            MsgBox "Verify all contact numbers on the account"
            Sess0.Screen.SendKeys ("<Home>for1<Enter>")

            msgtex = "Is the foreclosure active?"
            answer3 = MsgBox(msgtex, 4 + 48 + 512, "Foreclosure Status")

            If answer3 = "6" Then
                MsgBox "Verfiy foreclosure status, click okay to continue"
                Sess0.Screen.SendKeys ("<Home>for3<Enter>")
                MsgBox "Review for U20, click okay to continue"
                Sess0.Screen.SendKeys ("<Pf8>")
                MsgBox "click okay to continue"
                Sess0.Screen.SendKeys ("<Pf8>")
                MsgBox "click okay to continue"
                Sess0.Screen.SendKeys ("<Pf8>")
                MsgBox "click okay to continue"
                Sess0.Screen.SendKeys ("<Home>lmt1<Enter>")
                MsgBox "Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
                Sess0.Screen.SendKeys ("<Home>lmtn<Enter>")

            Else
                If answer3 = "7" Then
                    Sess0.Screen.SendKeys ("<Home>lmt1<Enter>")
                    MsgBox "Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
                    Sess0.Screen.SendKeys ("<Home>lmt3<Enter>")
                    MsgBox "Review for a populated L14. If blank, solicit payment per hierarchy"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Home>lmtn<Enter>")


                End If
            End If

        Else
            If answer2 = "7" Then
                Sess0.Screen.SendKeys ("<Home>dlq1<Enter>")
                Sess0.Screen.SendKeys ("<Home><Tab><Tab>mort<Enter>")
                MsgBox "Verify customer name, property address, mailing address, and last four of social security number. Also look for cease and desist banner as well"
                Sess0.Screen.SendKeys ("<Home>mem1<Enter>")
                MsgBox "Verify all A3P/Attorney contacts in MEM1"
                Sess0.Screen.SendKeys ("<Pf8>")
                MsgBox "click okay to continue"
                Sess0.Screen.SendKeys ("<Pf8>")
                MsgBox "click okay to continue"
                Sess0.Screen.SendKeys ("<Pf8>")
                MsgBox "click okay to continue"
                Sess0.Screen.SendKeys ("<Home>saf1<Enter>")
                Sess0.Screen.SendKeys ("<Pf8>")
                MsgBox "Verify the cease and desist code"
                Sess0.Screen.SendKeys ("<Home>dlq1<Enter>")
                Sess0.Screen.SendKeys ("<Home><Tab><Tab>mort<Enter>")
                MsgBox "Review mancode to read appropriate disclaimer and recording script"
                Sess0.Screen.SendKeys ("<Home>dlq8<Enter>")
                MsgBox "Verify all contact numbers on the account"
                Sess0.Screen.SendKeys ("<Home>for1<Enter>")
 
                msgtex = "Is the foreclosure active?"
                answer3 = MsgBox(msgtex, 4 + 48 + 512, "Foreclosure Status")

                If answer3 = "6" Then
                    MsgBox "Verfiy foreclosure status, click okay to continue"
                    Sess0.Screen.SendKeys ("<Home>for3<Enter>")
                    MsgBox "Review for U20, click okay to continue"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Home>lmt1<Enter>")
                    MsgBox "Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
                    Sess0.Screen.SendKeys ("<Home>lmtn<Enter>")

                Else
                    If answer3 = "7" Then
                        Sess0.Screen.SendKeys ("<Home>lmt1<Enter>")
                        MsgBox "Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
                        Sess0.Screen.SendKeys ("<Home>lmt3<Enter>")
                        MsgBox "Review for a populated L14. If blank, solicit payment per hierarchy"
                        Sess0.Screen.SendKeys ("<Pf8>")
                        MsgBox "click okay to continue"
                        Sess0.Screen.SendKeys ("<Pf8>")
                        MsgBox "click okay to continue"
                        Sess0.Screen.SendKeys ("<Pf8>")
                        MsgBox "click okay to continue"
                        Sess0.Screen.SendKeys ("<Home>lmtn<Enter>")

                    End If
                End If
            End If
        End If
    Else
        If answer1 = "7" Then
        
            msgtex = "Are you speaking to a third party"
            answer5 = MsgBox(msgtex, 4 + 48 + 256, "Compliance Tool")
            
            If answer5 = "6" Then
                Sess0.Screen.SendKeys ("<Home>mem1<Enter>")
                MsgBox "Verify all A3P/Attorney contacts in MEM1"
                Sess0.Screen.SendKeys ("<Pf8>")
                MsgBox "click okay to continue"
                Sess0.Screen.SendKeys ("<Pf8>")
                MsgBox "click okay to continue"
                Sess0.Screen.SendKeys ("<Pf8>")
                MsgBox "click okay to continue"
                Sess0.Screen.SendKeys ("<Home>saf1<Enter>")
                Sess0.Screen.SendKeys ("<Pf8>")
                MsgBox "Verify the cease and desist code"
                Sess0.Screen.SendKeys ("<Home>dlq1<Enter>")
                Sess0.Screen.SendKeys ("<Home><Tab><Tab>mort<Enter>")
                MsgBox "Verify customer name, property address. Also look for cease and desist banner as well"
                MsgBox "Review mancode to read appropriate disclaimer and recording script"
                Sess0.Screen.SendKeys ("<Home>dlq8<Enter>")
                MsgBox "Verify all contact numbers on the account"
                Sess0.Screen.SendKeys ("<Home>for1<Enter>")
                
                msgtex = "Is the foreclosure active?"
                answer6 = MsgBox(msgtex, 4 + 48 + 256, "Foreclosure Status")
                
                If answer6 = "6" Then
                    MsgBox "Verfiy foreclosure status, click okay to continue"
                    Sess0.Screen.SendKeys ("<Home>for3<Enter>")
                    MsgBox "Review for U20, click okay to continue"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Home>lmt1<Enter>")
                    MsgBox "Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
                    Sess0.Screen.SendKeys ("<Home>lmtn<Enter>")
                
                Else
                    If answer6 = "7" Then
                    Sess0.Screen.SendKeys ("<Home>lmt1<Enter>")
                    MsgBox "Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
                    Sess0.Screen.SendKeys ("<Home>lmt3<Enter>")
                    MsgBox "Review for a populated L14. If blank, solicit payment per hierarchy"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Home>lmtn<Enter>")
                    
                    End If
                End If
                
            Else
                If answer5 = "7" Then
                    Sess0.Screen.SendKeys ("<Home>dlq1<Enter>")
                    Sess0.Screen.SendKeys ("<Home><Tab><Tab>mort<Enter>")
                    MsgBox "Verify customer name, property address. Also look for cease and desist banner as well"
                    Sess0.Screen.SendKeys ("<Home>mem1<Enter>")
                    MsgBox "Verify all A3P/Attorney contacts in MEM1"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "click okay to continue"
                    Sess0.Screen.SendKeys ("<Home>saf1<Enter>")
                    Sess0.Screen.SendKeys ("<Pf8>")
                    MsgBox "Verify the cease and desist code"
                    Sess0.Screen.SendKeys ("<Home>dlq1<Enter>")
                    Sess0.Screen.SendKeys ("<Home><Tab><Tab>mort<Enter>")
                    MsgBox "Review mancode to read appropriate disclaimer and recording script"
                    Sess0.Screen.SendKeys ("<Home>dlq8<Enter>")
                    MsgBox "Verify all contact numbers on the account"
                    Sess0.Screen.SendKeys ("<Home>for1<Enter>")
                    
                    
                    msgtex = "Is the foreclosure active?"
                    answer7 = MsgBox(msgtex, 4 + 48 + 256, "Foreclosure Status")
                    
                    If answer7 = "6" Then
                        MsgBox "Verfiy foreclosure status, click okay to continue"
                        Sess0.Screen.SendKeys ("<Home>for3<Enter>")
                        MsgBox "Review for U20, click okay to continue"
                        Sess0.Screen.SendKeys ("<Pf8>")
                        MsgBox "click okay to continue"
                        Sess0.Screen.SendKeys ("<Pf8>")
                        MsgBox "click okay to continue"
                        Sess0.Screen.SendKeys ("<Pf8>")
                        MsgBox "click okay to continue"
                        Sess0.Screen.SendKeys ("<Home>lmt1<Enter>")
                        MsgBox "Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
                        Sess0.Screen.SendKeys ("<Home>lmtn<Enter>")
                    
                    Else
                        If answer7 = "7" Then
                            Sess0.Screen.SendKeys ("<Home>lmt1<Enter>")
                            MsgBox "Review status and assigned SPOC, offer to transfer call to SPOC or handle the call. Inform customer you will email the HPS of the call if handled by you"
                            Sess0.Screen.SendKeys ("<Home>lmt3<Enter>")
                            MsgBox "Review for a populated L14. If blank, solicit payment per hierarchy"
                            Sess0.Screen.SendKeys ("<Pf8>")
                            MsgBox "click okay to continue"
                            Sess0.Screen.SendKeys ("<Pf8>")
                            MsgBox "click okay to continue"
                            Sess0.Screen.SendKeys ("<Pf8>")
                            MsgBox "click okay to continue"
                            Sess0.Screen.SendKeys ("<Home>lmtn<Enter>")
                        End If
                    End If
                End If
            End If
        End If
    End If
End Sub 

RE: Unable to close out my code

(OP)
Perfect! Thanks Remy - I see where I wasn't making the connection now and it runs perfect

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