Results 1 to 2 of 2

Thread: Excel macro sending commands to another application, pasting results into Excel

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Excel macro sending commands to another application, pasting results into Excel

    [This was previously posted to Microsoft Community, I got a couple of questions/suggestions but no resolution.]

    I want to run reports in another application (Avaya) and paste results into Excel. I did this several years ago with Excel 2003 in an earlier OS but can't get it to work now.

    I open four reports in Avaya, and when I click the Excel button (on the sheet I want the reports pasted to) it checks the reports are open. If any aren't it tells me to, then to restart.

    If successful checking for the necessary Avaya reports, Excel then prompts me for a date, and sends the date to the first Avaya report with Sendkeys and DoEvents, then runs the report and copies the results to the clipboard. The next macro lines here are

    AppActivate ThisApp 'goes back to Excel
    Range("E4").Select
    Workbook.Activesheet.Paste

    Where it is supposed to paste the copied report into Excel. The cell E4 is selected, But at this point I get the Run-time error "424' Object required, with the last command above highlighted when I click Debug. If I manually paste in the selected cell, the last macro line is what is pasted.

    I use Activesheet because there are numerous sheets in the workbook, one for every day. I figure it should go back to the sheet where I originally clicked the macro button.

    Suggestions?

    ----------------------
    Per suggestion, I substituted "ActiveWorkbook.ActiveSheet.Paste" but it still doesn't work. Different error message now > Run-time error '1004': Paste Method of Worksheet class failed. Debug shows the substituted verbiage (still in the last macro line) is now highlighted.
    ----------------------

    Additional post by me >

    Apparently there is another part of my code that doesn't know the new lingo

    AppActivate Calls1
    Do While FindWindow(vbNullString, Calls1) = 0
    DoEvents
    Loop
    SendKeys "%r+%r", True
    DoEvents
    SendKeys "{tab 2}" + When, True
    DoEvents
    SendKeys "%w+{tab}", True
    DoEvents

    "AppActivate Calls1" does indeed activate the appropriate window of the Avaya application. But it apparently doesn't understand the "FindWindow(vbNullString, Calls1) = 0" statement. When I put the cursor on FindWindow and press F1 I get the message "Object library invalid or contains references to objexct definitions that could not be found." Tools/References in the VB window shows no obvious problems.

    What I am trying to do is put the focus on another app window (Calls1), then send keystrokes to it. The problem is that the SendKeys statement is sending those commands to the VB window, not to the Calls1 application that was activated. Any ideas?

    As I said previously, I am trying to make code that worked with a previous OS and Excel 2003 do similar things now. I have the feeling that the new OS (Windows 7 Enterprise) and the new Excel (2010) don't talk to each other like the old OS and the old Excel. Suggestions?

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Steve, it will be very difficult for anyone to comment or even start to provide any solution. One probable route would be to check whether Avaya provides any library/dll/ocx which you can use to automate using VBA?
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Replies: 26
    Last Post: 10-22-2019, 02:39 PM
  2. Replies: 1
    Last Post: 02-14-2013, 11:08 AM
  3. Replies: 7
    Last Post: 08-08-2012, 10:24 AM
  4. Replies: 3
    Last Post: 02-20-2012, 12:54 AM
  5. Excel Application.OnKey With Parameter
    By Excel Fox in forum Excel Help
    Replies: 0
    Last Post: 11-29-2011, 01:31 PM

Posting Permissions

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