Jump to content
Macro Express Forums

foray

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by foray

  1. Works great, thank you.

     

    I have a fix for this. I use it as a function because its rather lengthly and pasting this in every time Ctrl + C makes for a long code. I just call the macro below to do all the clipboard coping and T1 is set to the clipboard contents.

     

     

    1. First there is a loop to do clipboard copy 5 times to make sure there is something on the clipboard
    2. Inside the clipboard copy loop is a loop that makes sure something is on the clipboard
    3. If something is on the clipboard the loops are exited and another loop is entered
    4. This second loop makes sure that the variable set from the clipboard is exactly what was on the clipboard

     

    Since windows uses a buffer for the clipboard i have experienced variables only getting half the clipboard, the second repeat fixes this.

  2. Hi, I have a macro which activates an Excel worksheet, moves to cell D3, reads the value of D3 and copies into Macro variable N3. It then moves to cell D18, reads the value of cell D18 and copies into variable N10. The last few days of testing, the macro has performed these executions flawlessly but this morning it started misbehaving: N3 was always zero, even though cell D3 = 500. The strange thing is that while the macro was not able to read cell D3, it was able to read cell D18 correctly. This is strange because the code block used to read each cell is identical (posted below).

     

    I re-ran the macro perhaps a dozen times but each time it failed to read cell D3 while at the same time correctly reading cell D18. Then it started working again. Sometimes I have the feeling that Macro Express behaves erratically and unpredictably, but I know there must be a logical explanation for it. I'd deeply appreciate having a deeper understanding of what is happening when Macro Express fails to read the Excel cell, so that I code the execution more reliably - thanks.

     

     

    // Switch to Excel worksheet
    Activate Window: "Microsoft Excel - Batch Process Symbol List.xls"
    Wait For Window Title: "Microsoft Excel - Batch Process Symbol List.xls"
    
    // Initialize Excel & Matrix cells - run Excel VBA code.
    Text Type: <ALT><F8>
    Delay 1 Seconds
    Text Type: InitializeCells
    Delay 1 Seconds
    
    
    // /////////////////////////////////////////////////////////////////////////////////////////
    // Initialize variables that point macro to a specific Excel sheet & cell
    // /////////////////////////////////////////////////////////////////////////////////////////
    // Set Text variable T53 = text string pointing to sheet 1, cell D3
    Variable Set String %T53% "'Sheet1'!D3"
    // Set Text variable T55 = text string pointing to sheet 1, cell D18
    Variable Set String %T55% "'Sheet1'!D18"
    
    
    // /////////////////////////////////////////////////////////////////////////////////////////
    // Initialize variables tracking current and previous symbol numbers processed
    // /////////////////////////////////////////////////////////////////////////////////////////
    // N2 is the ID value of the CURRENT symbol - initialize
    Variable Set Integer %N2% to 0
    // N12 is the ID value of the PREVIOUS symbol - initialize
    Variable Set Integer %N12% to 0
    
    
    // /////////////////////////////////////////////////////////////////////////////////////////
    // INITIALIZE FINAL SYMBOL NUMBER (RETRIEVE FROM EXCEL SHEET) = N3
    // /////////////////////////////////////////////////////////////////////////////////////////
    // Go to Excel cell D3
    Text Type: <CTRL>g
    Text Type: %T53%
    Text Type: <ENTER>
    // Copy Cell D3 contents to Clipboard
    Clipboard Empty
    Clipboard Copy
    // Paste into numeric variable N3
    Variable Set Integer %N3% from Clipboard
    
    
    // /////////////////////////////////////////////////////////////////////////////////////////
    // RETRIEVE USER DEFINED POLL DELAY (RETRIEVE FROM EXCEL SHEET) = N10
    // /////////////////////////////////////////////////////////////////////////////////////////
    // Go to Excel cell D18
    Text Type: <CTRL>g
    Text Type: %T55%
    Text Type: <ENTER>
    // Copy Cell D18 contents to Clipboard
    Clipboard Empty
    Clipboard Copy
    // Paste into numeric variable N10
    Variable Set Integer %N10% from Clipboard

×
×
  • Create New...