Link to home
Start Free TrialLog in
Avatar of ArisaAnsar
ArisaAnsarFlag for United States of America

asked on

Visual Basic Error Message: Do Without Loop

I have the following Visusal Basic code and is getting an error message when running the code.  The error message is:  Compile Error:   Do Without Loop.   What am I missing?

VB Code.

Public Sub EFeed()
Range("a2").Activate

        MyScn.SendKeys "<Clear>"                            'hit clear twice
        MyScn.SendKeys "<Clear>"
        MyScn.SendKeys "scma<ENTER>"                        'type sjen
   
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
        account = ActiveCell.Value
        MyScn.PutString account, 14, 35
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
        Do While Not IsEmpty(ActiveCell)

        MyScn.PutString "3", 21, 9
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
Do While Not IsEmpty(ActiveCell)
        ADM = ActiveCell.Offset(0, 1).Value
        MyScn.PutString ADM, 15, 49
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
                       
        If MyScn.GetString(24, 18, 12) = "SUCCESSFULLY" Then
            ActiveCell.Offset(0, 2) = "OK"
        Else: ActiveCell.Offset(0, 2) = "NOT PROCESSED"
        End If
       
        If IsEmpty(ActiveCell.Offset(1, 0)) Then Exit Do
       
        ActiveCell.Offset(1, 0).Activate
        account = ActiveCell.Value
        MyScn.PutString account, 23, 17
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
Loop


End Sub
Avatar of madhubabus
madhubabus

loop statement missing for the below line

        Do While Not IsEmpty(ActiveCell)
there are 2 such statements and only one closing "loop" exists.

        Do While Not IsEmpty(ActiveCell)
Avatar of ArisaAnsar

ASKER

Thank you for responding so quickly.    I see closing loop for both.  Which of the two do you see it missing from?  

Do While Not IsEmpty(ActiveCell)

        MyScn.PutString "3", 21, 9
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
Do While Not IsEmpty(ActiveCell)
        ADM = ActiveCell.Offset(0, 1).Value
        MyScn.PutString ADM, 15, 49
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
................
..........
        Do While Not IsEmpty(ActiveCell)                    ////////////////loop is missing for this do while

        MyScn.PutString "3", 21, 9
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
Do While Not IsEmpty(ActiveCell)                             /////////////////////This is closed at the end
        ADM = ActiveCell.Offset(0, 1).Value
        MyScn.PutString ADM, 15, 49
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
                       
        If MyScn.GetString(24, 18, 12) = "SUCCESSFULLY" Then
            ActiveCell.Offset(0, 2) = "OK"
        Else: ActiveCell.Offset(0, 2) = "NOT PROCESSED"
        End If
       
        If IsEmpty(ActiveCell.Offset(1, 0)) Then Exit Do
       
        ActiveCell.Offset(1, 0).Activate
        account = ActiveCell.Value
        MyScn.PutString account, 23, 17
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
Loop                                                   ////////////////// this loop for the second while
Where would the other Loop statement have to placed?  I tried a few options but getting a debug error.
ASKER CERTIFIED SOLUTION
Avatar of madhubabus
madhubabus

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you.
I needed to remove the Do While Not IsEmpty (ActiveCell).

Thank you!