Re: [libreoffice-users] CALC - copy formula via macro

2011-09-04 Thread Andrew Douglas Pitonyak


On 09/02/2011 12:21 PM, Bill Gradwohl wrote:

Assume:

A1 contains the formula =SUM(B1:E1)

I want to programatically copy A1's formula to somewhere else in column
A that is determined at execution time, and I need the cell references
adjusted accordingly.

If it gets copied to A19, for example, I need the formula to read:
=SUM(B19:E19)

The getFormula and setFormula methods don't adjust the relative
references - they get and set text.

Is there a way to get the references adjusted auto-magically?
Is there a method that can take the formula obtained via the getFormula
and apply a row and column distance offset to the contents?

I don't want to use the macro recorder/dispatcher - too ugly.




  Dim o
  Dim oSheet
  Dim oRange
  Dim oDoc

  oRange = oDoc1.Sheets(0).getCellRangeByName(B2:C3)
  oDoc1.CurrentController.select(oRange)
  o = oDoc1.CurrentController.getTransferable()

  oRange = oDoc2.Sheets(0).getCellRangeByName(F1)
  oDoc2.CurrentController.select(oRange)
  oDoc2.CurrentController.insertTransferable(o)

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info:  http://www.pitonyak.org/oo.php


--
For unsubscribe instructions e-mail to: users+h...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted



Re: [libreoffice-users] CALC - copy formula via macro

2011-09-04 Thread Bill Gradwohl
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 09/04/2011 07:38 PM, Andrew Douglas Pitonyak wrote:
 
   Dim o
   Dim oSheet
   Dim oRange
   Dim oDoc
 
   oRange = oDoc1.Sheets(0).getCellRangeByName(B2:C3)
   oDoc1.CurrentController.select(oRange)
   o = oDoc1.CurrentController.getTransferable()
 
   oRange = oDoc2.Sheets(0).getCellRangeByName(F1)
   oDoc2.CurrentController.select(oRange)
   oDoc2.CurrentController.insertTransferable(o)
 


Andrew:

I'm going to have to study this one.

GetTransferable / insertTransferable - Never heard of them!



- -- 
Bill Gradwohl
Roatan, Honduras
504 9 899 2652
IM:billgradw...@gmail.com (No email please-IM only)
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk5kRz4ACgkQ7Orvev+eC8qdkQCgtdzPAwRSQPvV3OWOTY4EH4fI
hWoAoJeBMO5zxfEbmnJZg9rTX1p0Mzgp
=+R9E
-END PGP SIGNATURE-

-- 
For unsubscribe instructions e-mail to: users+h...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted



Re: [libreoffice-users] CALC - copy formula via macro

2011-09-03 Thread Johnny Rosenberg
2011/9/2 Bill Gradwohl bill-l...@ycc.com:
 Assume:

 A1 contains the formula =SUM(B1:E1)

 I want to programatically copy A1's formula to somewhere else in column
 A that is determined at execution time, and I need the cell references
 adjusted accordingly.

 If it gets copied to A19, for example, I need the formula to read:
        =SUM(B19:E19)

 The getFormula and setFormula methods don't adjust the relative
 references - they get and set text.

 Is there a way to get the references adjusted auto-magically?
 Is there a method that can take the formula obtained via the getFormula
 and apply a row and column distance offset to the contents?

 I don't want to use the macro recorder/dispatcher - too ugly.


 --
 Bill Gradwohl
 Roatan, Honduras

Did you explore the possibilities of ”com.sun.star.table.CellAddressConversion”?
If not, take a look at Listing 416 in http://www.pitonyak.org/OOME_3_0.pdf

Even if you can't use it in this situation, it might be good reading anyway…


Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ

-- 
For unsubscribe instructions e-mail to: users+h...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted


[libreoffice-users] CALC - copy formula via macro

2011-09-02 Thread Bill Gradwohl
Assume:

A1 contains the formula =SUM(B1:E1)

I want to programatically copy A1's formula to somewhere else in column
A that is determined at execution time, and I need the cell references
adjusted accordingly.

If it gets copied to A19, for example, I need the formula to read:
=SUM(B19:E19)

The getFormula and setFormula methods don't adjust the relative
references - they get and set text.

Is there a way to get the references adjusted auto-magically?
Is there a method that can take the formula obtained via the getFormula
and apply a row and column distance offset to the contents?

I don't want to use the macro recorder/dispatcher - too ugly.


-- 
Bill Gradwohl
Roatan, Honduras


-- 
For unsubscribe instructions e-mail to: users+h...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted