Results 1 to 1 of 1

Excel Macro Sends Command When Prompted by AS400 Style System

Threaded View

  1. #1
    Registered User
    Join Date
    01-14-2013
    Location
    Fort Worth, TX
    MS-Off Ver
    Excel 2003
    Posts
    4

    Excel Macro Sends Command When Prompted by AS400 Style System

    Hi,

    Let me begin by thanking everyone in advance for any assistance with this macro problem. A little background: I currently have a very simple Excel macro that will send information contained in cells, one cell at a time, to another macro I have created in an AS/400 style system. The AS/400 style system will prompt for information (for example, name), and the Excel macro will send that information to the prompt, simulate Enter key (creating a new prompt in the AS/400 system), move to the next cell, send the information, etc. over and over until it reaches the last cell with information.

    This works fine, however, the only way I know of "timing" the sending of information from Excel is using .Wait Now + TimeValue("0:00:01"). The issue with this is, sometimes the AS/400 system will hang after simulating Enter keystroke, but the Excel macro continues running at a single pace, resulting in some information not being sent properly. Furthermore, if Excel could send information when prompted, instead of waiting a second for each command, my process could be significantly sped up.

    My question: is there some kind of way to build into the Excel macro to only send information when a valid prompt is up in the AS/400 system? I have attached a picture of the AS/400 type of prompt I'm speaking of, as well as my very simple macro to feed information to the system.

    Const CA = "AS/400 System"
    Const XL = "Microsoft Excel"
    
    Sub QuickJournal()
       ' Quickly processes journals in (CA) window
       
       Dim AMOUNT As String
       Dim SYMBOL As String
        
       Do Until ActiveCell = ""
       
       SYMBOL = ActiveCell.Value
       
       AppActivate (CA)
       
       With Application
        .Wait Now + TimeValue("0:00:01")
        .SendKeys SYMBOL
        .Wait Now + TimeValue("0:00:01")
        .SendKeys ("~")
        End With
        
        AppActivate (XL)
        
        ActiveCell.Offset(0, 1).Activate
        
        AMOUNT = ActiveCell.Value
        
        AppActivate (CA)
        
        With Application
        .Wait Now + TimeValue("0:00:01")
        .SendKeys AMOUNT
        .Wait Now + TimeValue("0:00:01")
        .SendKeys ("~")
        End With
        
        AppActivate (XL)
        
        ActiveCell.Offset(1, -1).Select
        
        Loop
        
        With Application
        .Wait Now + TimeValue("0:00:01")
        End With
        
    End Sub
    Again, any assistance with this question is greatly appreciated!
    Attached Images Attached Images

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1