Jump to content
Macro Express Forums

Drop one line in Excel 2007


Recommended Posts

I need to drop down one line every time I go back into Excel. Here is the basic of what I'm trying to do.

 

<WINDOW ACTIVATE Title="Microsoft Excel" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>

<MOUSE LEFT CLICK/>

<GET MOUSE POSITION Option="\x01" X="%N[1]%" Y="%N[2]%"/>

<DELAY Flags="\x01" Time="2"/>

<MOUSE MOVE Option="\x01" X="300" Y="300" _PROMPT="0x000A"/>

<DELAY Flags="\x01" Time="2"/>

<GET MOUSE POSITION Option="\x01" X="%N[1]%" Y="%N[2]%"/>

<DELAY Flags="\x01" Time="2"/>

<TEXT TYPE Action="0" Text="<ARROW DOWN><ENTER>"/>

 

It is not going down a line nor is it showing an active cell. Since I can not see an active cell, maybe it is going down a line.

 

 

Bob

Link to comment
Share on other sites

I need to drop down one line every time I go back into Excel. Here is the basic of what I'm trying to do.

 

<WINDOW ACTIVATE Title="Microsoft Excel" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>

<MOUSE LEFT CLICK/>

<GET MOUSE POSITION Option="\x01" X="%N[1]%" Y="%N[2]%"/>

<DELAY Flags="\x01" Time="2"/>

<MOUSE MOVE Option="\x01" X="300" Y="300" _PROMPT="0x000A"/>

<DELAY Flags="\x01" Time="2"/>

<GET MOUSE POSITION Option="\x01" X="%N[1]%" Y="%N[2]%"/>

<DELAY Flags="\x01" Time="2"/>

<TEXT TYPE Action="0" Text="<ARROW DOWN><ENTER>"/>

 

It is not going down a line nor is it showing an active cell. Since I can not see an active cell, maybe it is going down a line.

 

 

Bob

 

What version of Excel are you using. In Excel 2007 you can use an Excel function to find the last cell in the spreadsheet.

 

[HOME] [FIND & SELECT] [GO TO SPECIAL] [LAST CELL]

 

If you add the [GO TO SPECIAL] menu item to your custom ribbon you can then access it with an ALT-'n' key sequence where 'n' is the numbered position of the shortcut icon on the ribbon.

 

Then getting to the next line from the last active cell would be ALT 'n' ALT s DOWN ARROW

 

Hope this helps.

 

Edit:

 

Excel should remember and return to the last active cell when you open it. Therefore you have an opportunity to set that position before you close the program.

Link to comment
Share on other sites

Just a quick observation: You have a Mouse Left Click command after the window activates. If the mouse is hovering over a different window, that click will cause Excel to lose focus, thereby defeating the rest of the macro.

 

I will now test your code for my own enjoyment.

 

Edit

Your macro doesn't do anything. At least it doesn't do anything like what you're trying to make it do.

 

Let me explain what your macro is doing, because from there we can work out what to change to make it do what you want it to do.

 

Window Activate: Microsoft Excel - I see no reason to change this at this time

 

Mouse Left-Click - You definitely want to make sure the mouse is hovering over Excel when you launch the macro.

 

Get Mouse Position into (%N[1]%, %N[2]%) Relative to Current Window - This is setting N1 and N2 to the coordinates of the mouse pointer relative to whatever window was underneath the mouse (hopefully Excel).

 

Delay: 2 seconds - Self explanatory

 

Mouse Move: 300, 300 Relative to Screen - Here is where I think you're most noticeable mistake is located (hence the RED). This command is moving your mouse pointer to 300 pixels down and 300 pixels over from the top left corner of your screen. I honestly don't know why you programmed that into this macro. Unless you are confident that your Excel window will always be maximized or at least always positioned in the top-left corner. Even then, I don't know why you are moving the mouse to that location. Hovering the mouse right there doesn't do anything.

 

If, by chance, you want it there so the next time you run the macro, the Mouse Click command highlights the cell located at 300 x 300, then it starts to make sense, except that it will ALWAYS be the same cell at that location, so you won't actually be doing anything productive after the first time you run it.

 

Delay: 2 seconds - 2 seconds is a pretty big delay for most macros. You might want to reduce these down a little

 

Get Mouse Position into (%N[1]%, %N[2]%) Relative to Current Window - This just updates the N1 and N2 coordinates to express where 300 x 300 on your screen is relative to the top left corner of your Excel page. I don't know that this would be useful information.

 

Delay: 2 seconds - again

 

Text Type (Simulate Keystrokes): <ARROW DOWN><ENTER> - This command is the one command that makes sense to me, considering what you're trying to do. But it won't work if you don't have a cell selected. And even if you do have a cell selected, you'll actually be going down twice (once with the Arrow Down, and again with the Enter).

 

What I think you probably want to do is drop the Mouse Position commands, because they don't appear to do anything, as well as the Mouse Click command.

 

As long as a cell is already selected, the following should work flawlessly:

 

<WINDOW ACTIVATE Title="Microsoft Excel" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>
<TEXT TYPE Action="0" Text="<ENTER>"/>

 

Yep, two lines:

Window Activate: Microsoft Excel
Text Type (Simulate Keystrokes): <ENTER>

Link to comment
Share on other sites

Mousing in Excel is always a bad idea IMHO and should be avoided at all costs. It's better to use arrow moves or better yet use the F5 goto command in Excel.

 

Text type F5

Wait for goto window

text type the cell you desire and hit enter

 

Badabing badaboom.

Link to comment
Share on other sites

Thoraldus - Tried what you said, but that doesn't go to the last cell that was active, it goes to the very last cell in the spreadsheet. I want to return the the last cell I was working in and then go down 1 line.

 

Steve - I will read what you posted a little more thoroughly and give it a try.

 

Like I said above I want to, while working in Excel, return to the last cell I was working in and then drop down a line to the next row.

 

Bob

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...