Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not moving onto next cell?

Status
Not open for further replies.

Crash171

Programmer
Sep 5, 2014
30
0
0
US
I think I'm missing something very small. This is a rather simple macro (so far) that I am building onto. The problem that I am having is that "Putstring" (highlighted below) is not putting the next row into attachmate after it completes the first loop.

Code:
        Dim xlApp As Object, xlSheet As Object, MyRange As Object
        Set xlApp = CreateObject("excel.application")
        xlApp.Application.DisplayAlerts = False 'Turn off Warning Messages'
        xlApp.Visible = True
        xlApp.Workbooks.Open FileName:="C:\Users/Macros/OrderTracking.xlsx"
        Set xlSheet = xlApp.ActiveSheet
        Set myRange = xlApp.ActiveSheet.Range("A:A")
  
Dim Row As Long
        With xlApp.ActiveSheet
           Set myRange = .Range("A2:A2000").Resize(xlApp.CountA(.Range("A2:A2000")))
        End With
        For Row = 1 To myRange.Rows.Count
        Sess0.Screen.Moveto 24,08
	Sess0.Screen.Sendkeys("ortk<Tab>o")
 	[highlight #73D216]Sess0.Screen.PutString myRange.Rows(Row).Value, 24, 28[/highlight]
	Sess0.Screen.Sendkeys("<Enter>")
            Do Until Sess0.Screen.WaitForCursor (24,08)
              DoEvents
            Loop
          XlSheet.cells(myrange.row+row-1, "B").value = Sess0.Screen.GetString(15,28,1)
          XlSheet.cells(myrange.row+row-1, "C").value = Sess0.Screen.GetString(12,68,5)
          XlSheet.cells(myrange.row+row-1, "D").value = Sess0.Screen.GetString(11,68,10)
          

          
        If (Sess0.Screen.GetString(15,28,1) = "s") or (Sess0.Screen.GetString(15,28,1) = "r") or (Sess0.Screen.GetString(15,28,1) = "e") or (Sess0.Screen.GetString(15,28,1) = "d") Then
          XlSheet.cells(myrange.row+row-1, "E").putstring = ("REJECTED / SUSPENDED")
        End if

          
           Sess0.Screen.Sendkeys("<Pf10>")   
                  
         Next Row
         
        xlApp.Quit
        Set xlApp = Nothing 
	System.TimeoutValue = OldSystemTimeout
End Sub
 
Hi,

So what's actually happening? Please explain exactly.

So what's your objective with that statement?
 
Oh sorry! I thought I put that part in there.

Objective: This is supposed to send the numbers in column A into Attachmate, run a command, then return the text from three areas of the screen into columns B, C, then D. Then it should move onto the next column.

Problem: It continually moves the number in cell a2 into Attachmate, instead of moving from a2 to a3 to a4 and so on. It does however successfully move the text from the three desired areas from Attachmate into Excel and those are put in the correct areas. (row 2, then 3, then 4).




Also, for now, ignore the below lines. They may or may not work, I just tossed them in as a note more than anything

Code:
        If (Sess0.Screen.GetString(15,28,1) = "s") or (Sess0.Screen.GetString(15,28,1) = "r") or (Sess0.Screen.GetString(15,28,1) = "e") or (Sess0.Screen.GetString(15,28,1) = "d") Then
          XlSheet.cells(myrange.row+row-1, "E").putstring = ("REJECTED / SUSPENDED")
        End if
 
WAIT!!!

I figured it out. It seems I was rushing the macro and not waiting for the system to be ready! I added in a "WaitForCursor" and I'm golden!!!!

ha!

Thanks yet again Skip for all your help over the last few months!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top