Jump to content
Macro Express Forums

Macro not behaving properly


Recommended Posts

Hello everyone

 

essentially what i'm doing here is copying a cell from excel, switching to another application, pasting it. then switching back and sending a right arrow key command to go to the next cell and repeat until it detects "STOP" in the clipboard.

 

 

then at the end of the macro it goes left left down to reset the position for a new line, and the macro repeats

 

 

i have been tinkering around with adding delays and such but for some reason it is skipping lines in excel, but everything else is behaving properly

 

for example it is SUPPOSED to go, right, right, then left left down to go to the beginning of the next line

 

but instead it goes right, down right, right, left left down

 

 

i verified my script and there is no down right command but it is doing it anyway. Does anyone have any idea what might cause this?

 

 

I have attached my script

 

Repeat Start (Repeat 50 times)

If Clipboard Contains "STOP"

Macro Stop

End If

Activate Window: "OpenOffice.org"

Delay 150 Milliseconds

Clipboard Copy

Delay 150 Milliseconds

Text Type: <ARROW RIGHT>

 

Delay 150 Milliseconds

Activate Window: "Toy Galaxy"

Delay 150 Milliseconds

Clipboard Paste

Text Type: <ENTER>

Delay 150 Milliseconds

Activate Window: "OpenOffice.org"

Delay 150 Milliseconds

Clipboard Copy

Delay 150 Milliseconds

Text Type: <ARROW RIGHT>

Delay 150 Milliseconds

Activate Window: "Toy Galaxy"

Delay 150 Milliseconds

Clipboard Paste

Text Type: <ENTER>

Delay 150 Milliseconds

Activate Window: "OpenOffice.org"

Delay 150 Milliseconds

Clipboard Copy

Text Type: <ARROW LEFT>

Delay 150 Milliseconds

Text Type: <ARROW LEFT>

Delay 150 Milliseconds

Text Type: <ARROW DOWN>

Delay 150 Milliseconds

Activate Window: "Toy Galaxy"

Delay 150 Milliseconds

Text Type: <CTRLD><SHIFTD><ARROW RIGHT>

 

Text Type: <CTRLU><SHIFTU>

Delay 150 Milliseconds

Clipboard Paste

Text Type: <ENTER><ENTER>

Delay 150 Milliseconds

Activate Window: "OpenOffice.org"

Delay 150 Milliseconds

Clipboard Copy

Repeat End

 

 

Here is the script without all the delays

 

Repeat Start (Repeat 50 times)

If Clipboard Contains "STOP"

Macro Stop

End If

Activate Window: "OpenOffice.org"

Clipboard Copy

Text Type: <ARROW RIGHT>

 

Activate Window: "Toy Galaxy"

Clipboard Paste

Text Type: <ENTER>

Activate Window: "OpenOffice.org"

Clipboard Copy

Text Type: <ARROW RIGHT>

Activate Window: "Toy Galaxy"

Clipboard Paste

Text Type: <ENTER>

Activate Window: "OpenOffice.org"

Clipboard Copy

Text Type: <ARROW LEFT><ARROW LEFT><ARROW DOWN>

Activate Window: "Toy Galaxy"

Text Type: <CTRLD><SHIFTD><ARROW RIGHT>

 

Text Type: <CTRLU><SHIFTU>

Clipboard Paste

Text Type: <ENTER><ENTER>

Activate Window: "OpenOffice.org"

Clipboard Copy

Repeat End

 

 

The weird thing is that it was working before I added the loop, and it worked one line per macro run

 

 

If anyone could possibly help it would be VERY MUCH APPRECIATED!!!!

 

Thanks!!

Link to comment
Share on other sites

I don’t have much time but I think you need to add some time after your clipboard commands in Excel. Excel does a whole lot of things when copy and pasting and there is often a short unresponsive period after that. Start at 500mS and work down.

 

I do a lot of this sort of thing with data in Excel and I never use Excel because of these problems. Here are my suggestions for how to do this much easier:

 

1- Save that data in a CSV or text file and use ASCII File Process or Text File Process. No switching back bad forth or even any need for Excel to be open at all.

 

2- Copy the entire range of cells to the clipboard and split into an array variable in MEP then use a repeat to process them. Often this is nice when the user often has varying ranges. I do this one a lot.

 

3- Use VBScript to directly extract the cell contents from the Excel Workbook. One doesn’t even need to have Excel open but it does need to be saved. This is my latest and preferred method. Also you can write back to the Workbook with VBS. VERY handy.

 

Let me know if you would like to learn more about any of these and I am available for hire if you would like me to create something for you and/or teach the methods.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...