Jump to content
Sign in to follow this  
aps

copying and pasting data from one application into 2 sheets in excel bombs after about 50 successful runs

Recommended Posts

HI !! I am a new comer and so hello to all. I have a problem as follows: While trying to lift data from an application and pasting it into two seperate sheets of an excel file, after about 40 to 50 successful pastes i get an error saying that the excel file is not fully loaded. i dont know why this occours and how to rectify it. The data from the application is lifed say from two notepad files, say np1 and np2. I am trying to simulate it as follows.

for count = 1 to x

activate np-1,

copy data,

activate myfile (excel file - sheet 1)

paste data

activate np-2,

copy data

activate myfile

switch to sheet 2 using the command command SEND ("^ {PGDN"})

paste data

switch to sheet 1 using the command command SEND ("^ {PGUP"})

next count

The program works ok for about 40 lifts and then bombs and i get an error saying "excel file not completely loaded or sth to that effect.

Can anybody help ?? any clues as to why i get this messege.

Thanks

Share this post


Link to post
Share on other sites

...any clues as to why i get this messege.

I do not get that error message using this code on a system running Xp SP2 and using Office 2003:
AutoItSetOption("WinTitleMatchMode", 2)
AutoItSetOption("WinWaitDelay", 1)
AutoItSetOption("SendKeyDelay", 1)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;make/place Book1.xls in the folder with this test script;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ShellExecute("Book1.xls")
WinWaitActive("Book1.xls")

Run("notepad")
WinWaitActive("Untitled")
WinSetTitle("Untitled", "", "np-1")
$info = ""
For $i = 1 To 100
    $info &= "np-1 Line " & $i & @CRLF
Next
ControlSetText("np-1", "", "Edit1", $info)

Run("notepad")
WinWaitActive("Untitled")
WinSetTitle("Untitled", "", "np-2")
$info = ""
For $i = 1 To 100
    $info &= "np-2 Line " & $i & @CRLF
Next
ControlSetText("np-2", "", "Edit1", $info)

For $i = 1 To 100
    ;activate np-1,
    WinActivate("np-1")
    WinWaitActive("np-1")

    ;copy data,
    ControlSend("np-1", "", "Edit1", "+{END}^c{HOME}{DOWN}")

    ;activate myfile (excel file - sheet 1)
    WinActivate("Book1.xls")
    WinWaitActive("Book1.xls")

    ;paste data
    ControlSend("Book1.xls", "", "XLDESK1", "^v{ENTER}")

    ;activate np-2,
    WinActivate("np-2")
    WinWaitActive("np-2")

    ;copy data,
    ControlSend("np-2", "", "Edit1", "+{END}^c{HOME}{DOWN}")

    ;activate myfile (excel file - sheet 1)
    WinActivate("Book1.xls")
    WinWaitActive("Book1.xls")

    ;switch to sheet 2 using the command command SEND ("^ {PGDN"})
    Send("^{PGDN}")

    ;paste data
    ControlSend("Book1.xls", "", "XLDESK1", "^v{ENTER}")

    ;switch to sheet 1 using the command command SEND ("^ {PGUP"})
    Send("^{PGUP}")
Next
See if you can run the code above.

-MSP-


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...