Andrew - thank you for your reply. I wish I understood a tenth of what you said. I have your book (used copy) on my wish list but still can't afford it (maybe some day). Do you suppose in the mean time you could put what you wrote into some dumber kind of language? I wrote some code in the early days (maybe 20 years ago). Forgot most everything I knew (all DOS based). Until I can get your book I'm clueless (I looked at the notes on your site and was completely bewildered. Thanks. ----- 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]

Reply via email to