Consulting

Results 1 to 2 of 2

Thread: Copying text from SmarTerm into Excel with VBA

  1. #1

    Copying text from SmarTerm into Excel with VBA

    Hi,

    I'm working on a macro to replace something we have been using for many years running in WRQ Reflection, but now have to run through SmarTerm instead.

    I've got the majority of the code worked out, and I'm able to copy using VBA into the relevant excel cells, however I'm currently using exact column/row references to select the data which isn't going to work for all of the needs of the report, as the position of the data in SmarTerm can change based on the results of the query.

    I'm using Session.StringWait.MatchString to find specific text to allow input, but for some reason I can't get this to work to then copy the entire row on which the found text is on, is this something that's possible with VBA & SmarTerm? I can't locate this as an option in the help manual they provide.

    Here's the code I've got currently for the search and select, currently the macro just hangs as it seems it can't find the specified text
    Session.StringWait.MatchString "SEARCH TEXT"    
        Session.StringWait.Start
        If Session.StringWait.Status = 1 Then
            SearchText = Session.SelectScreenAtCoords(Session.FoundTextRow, 20, Session.FoundTextRow, 45)
            If SearchText Then
            SearchText$ = Session.ScreenText(Session.FoundTextRow, 20, 1, 25)
            rng_Range_Constants_Col_A.Offset(0, 4).Value = "SEARCH TEXT: " & SearchText$
            Else
            rng_Range_Constants_Col_A.Offset(0, 4).Value = "NOTHING FOUND"
            End If
        End If
    FoundTextRow was something we used in the old Macro, I don't know if this will continue to work with SmarTerm or not, so if not if there's an alternative I need to use I'd welcome support/suggestions on this.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    I have no clue what the code isd oing, but this may help :

    Session.StringWait.MatchString "SEARCH TEXT" 
    Session.StringWait.Start 
    
    Const Secs As Double  = 0.000011574   'Seconds = 1 / 24 * 60 * 60
    Do while Session.StringWait.Status = [Not ready for Primetime] '???
    Application.Wait (Now + 2 * Secs)
    DoEvents
    Loop
    
    If Session.StringWait.Status = 1 Then 
        SearchText = Session.SelectScreenAtCoords(Session.FoundTextRow, 20, Session.FoundTextRow, 45) 
        If SearchText Then 
            SearchText$ = Session.ScreenText(Session.FoundTextRow, 20, 1, 25) 
            rng_Range_Constants_Col_A.Offset(0, 4).Value = "SEARCH TEXT: " & SearchText$ 
        Else 
            rng_Range_Constants_Col_A.Offset(0, 4).Value = "NOTHING FOUND" 
        End If 
    End If
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •