Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 12-13-2006, 01:14 AM   #1
Registered: Sep 2003
Location: Qingdao, China
Distribution: mandriva, slack, red flag
Posts: 249

Rep: Reputation: 31
HOW-TO dynamic filename in spreadsheet formula


This example uses the OpenOffice spreadsheet program.

The purpose of this is to show you how you can have a dynamic filename linked in your spreadsheet.
For example,
you want cell B2 in your spreadsheet to be taken from the spreadsheet /12.ods, sheet 1, cell A1.

But you want to do this everyday, and the filename is going to be whatever day of the month it is.

So, tomorrow, the file would be named 13.ods, because tomorrow is the 13th of December. The next day it would be named 14.ods.

You're going to use this macro to do this:

Sub ExampleSetValue
Dim oDoc As Object, oSheet As Object, oCell As Object
oCell = thiscomponent.sheets(0).getcellbyposition(1,1)
oCell.setFormula("='" & DAY(NOW()) & ".ods'#$Sheet1.A1")
End Sub

(one note: the (1,1) in getcellposition refers to B2, (0,0) would be A1)

You're all set.

To learn how to use macros in OOffice by example, read on:

First, open a new spreadsheet. Fill in cell A1 with any number. Save it as today's date.ods. (For example, if today is Dec 15, save the file as 15.ods.)

Second, open a new spreadsheet. Save it as

Tools -> Macros -> Organize Macros -> Basic...

Create a new macro under the filename test.ods.

Delete all the other stuff in the macro and copy and paste the macro I gave you before into it.

Save it and bring the sheet test.ods back up.

Tools -> Macros -> Run Macro...

Find your macro under test.ods and run it.

The number you entered into today's date.ods sheet1 A1 should now appear in test.ods sheet1 B2.

If you have any questions, don't hesitate to ask.

If this has helped you, please write a quick thank you note.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert static library (Filename.a) to dynamic shared object ( afx2029 Linux - Software 4 08-17-2007 07:07 AM
Crypto Formula rubadub Programming 2 09-06-2006 11:16 AM
Bitwise >> formula concept... debiant Programming 10 08-31-2006 09:28 PM
open office formula editor Four Linux - Newbie 1 03-30-2006 10:46 PM
change uploaded files from filename.avi to filename.avi.html like latheesan Linux - Newbie 3 06-16-2005 05:33 AM

All times are GMT -5. The time now is 05:22 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration