Mac McClain wrote:

Andrew - thank you for your reply.

Your welcome

Do you suppose in the mean time you could put what you wrote into some dumber kind of language?

Sure, here it is in easy language...

* Based on your initial message I was not certain what you really wanted to do; so I guessed for some of it.

* Assume that you want to visit me so you ask me where I live. I might give you an absolute answer as in (My GPS cooridinates are .....), or, if I know that you are currently three houses down, I might tell you to go north three houses, and then turn right. I will call these two methods "absolute" and "relative". When you record a macro, it is likely to do things as though they are absolute. It sounds to me like you wanted the recorded macro to be relative to where your cursor was located.

* I think that you wanted a macro that inserted a row at the cursor, so I wrote a macro that inserts a row at the cursor.

* I did nothing else, because you did not say what you wanted the macro to do. I would say that you wanted to insert a row at the cursor and then copy some cells from somewhere.

I wrote some code in the early days (maybe 20 years ago).

Excellent.

Forgot most everything I knew

Not excellent.

(all DOS based).

I did a lot of stuff in DOS

Until I can get your book I'm clueless (I looked at the notes on your site and was completely bewildered. Thanks.

Start with the small stuff. Are you able to read the example that I posted and understand what it does?
Are you able to run the macro?

----- Original Message ----- From: "Andrew Douglas Pitonyak" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Saturday, July 29, 2006 8:53 AM
Subject: Re: [users] Using a Macro


Mac McClain wrote:

I created (using record macro) a simple macro to insert a row, hilite a few things and copy them up to the line where the insertion was done. Easy enough. The repeat of this is pretty cumbersome but worse than that it will always do the insert and copy at the same spot. How do I get it to understand that the insertion should start where the hilited cell currently is? Thanks in advance.

You did not post the generated macro, but I would guess that if you look at it, that it includes hard coded addresses such as "D14" rather than by inspecting the location of the active cell. One could argue for either case...

What would you like the macro to do?
It is my guess that you want your macro to

* Notice the currently active cell. Ask yourself, what should the macro do if you happened to select more than a single cell? I will assume that the answer is "I only care about the currently active cell".

Now, insert a row at the active cell. The "1" for insertByIndex indicates that only one row should be inserted...

 Dim oRanges     'A blank range created by the document
 Dim oCell       'The current active cell
 Dim oSheet      'Currently active sheet

REM Select an empty range object to leave the cursor in only the active cell. REM The purpose is to make certain that more than a single cell is not selcted. oRanges = ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
 ThisComponent.CurrentController.Select(oRanges)
 oCell = ThisComponent.CurrentSelection
 oSheet = oCell.getSpreadsheet()
 oSheet.getRows().insertByIndex(oCell.getCellAddress.Row, 1)

I hope that this provides a nice start...


--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to