I recently updated Open Office and clicked the wrong button and lost all the macros and the dialog that I had spent so long on. They were nowhere to be found. However, in looking through computer files and then finally doing a search at the OpenOffice Forum, I now know where my newly created macros are -- which doesn't help too much since they're pretty well buried.
However, while playing around, I found out that one can "export" a library of macros and dialogs. So, now I have the library that I'm recreating copied to a folder on the desktop. It could be worse. I still have my old Visual Basic macros and dialog.
Friday, September 29, 2006
Saturday, June 24, 2006
load speed
It's amazing what a little change can make. I was complaining to one of my sons about how slow Open Office loaded. He went to options and unchecked Java runtime environment. Now Open Office loads much more quickly.
Monday, March 06, 2006
objects
I don't know if I just didn't know enough Visual Basic to make full use of objects. However, I'm finding that it's natural to change the find-something-or-other functions that I wrote to return an object instead of a boolean and then to check the object to see if it has the characteristic (such as the right string value) that I was searching for. (The FindFirst function that comes with OOo Basic returns an object -- a cell -- if the search was successful.) I'm also finding that I'm not creating temporary range names (as I did in VB) but instead just using oCell= or oRange= .
On another vein, I also find I'm liking using the Input function followed by a MsgBox function that says in effect "Are you sure?" as recommended in the Help info for Input function.
On another vein, I also find I'm liking using the Input function followed by a MsgBox function that says in effect "Are you sure?" as recommended in the Help info for Input function.
Friday, March 03, 2006
sorting
I was reading the OpenOffice forum message boards and saw a question about sorting on more than 3 categories. I haven't joined the forum since I know very little about Basic but thought I'd at least write down my thoughts somewhere. To sort on, say, 5 categories, first sort on the last two then sort the result on the first 3.
Finally, I'm finding that it isn't as hard as I thought to rewrite macros from Visual Basic to OOo Basic. There are a few differences to keep one on one's toes, of course. A few of the provided macro functions are different (like IFF instead of IF for the function). The workbook functions are mostly the same -- except for using semicolons instead of commas to separate elements.
Finally, I'm finding that it isn't as hard as I thought to rewrite macros from Visual Basic to OOo Basic. There are a few differences to keep one on one's toes, of course. A few of the provided macro functions are different (like IFF instead of IF for the function). The workbook functions are mostly the same -- except for using semicolons instead of commas to separate elements.
Wednesday, February 08, 2006
Changing controls in a dialog
oControl = oDialog1.getControl("ComboBox1")
msgbox oControl.itemcount
msgbox oControl.text
oControl = oDialog1.GetControl("Label1")
msgbox oControl.text
oControl.text = "kitty"
oControl = oDialog1.GetControl("CheckBox1")
msgbox oControl.state
oDialog1Model = oDialog1.Model
oControlModel = oDialog1Model.CheckBox1
oControlModel.state = 1
oControlModel.label = "hello"
msgbox oControl.itemcount
msgbox oControl.text
oControl = oDialog1.GetControl("Label1")
msgbox oControl.text
oControl.text = "kitty"
oControl = oDialog1.GetControl("CheckBox1")
msgbox oControl.state
oDialog1Model = oDialog1.Model
oControlModel = oDialog1Model.CheckBox1
oControlModel.state = 1
oControlModel.label = "hello"
Thursday, February 02, 2006
Range entries to listbox
Again, there's probably an easier way to do this, but this works to copy entries from a spreadsheet range to a listbox (or combobox) in a dialog.
rngname="Jason" 'the name of the range (one column by unknown number of rows)
oNamedRange = ThisComponent.NamedRanges.getByName(rngname)
sName = oNamedRange.getContent() 'gives full address starting with $
xPos = InStr(1,sName,".") - 2 'sheet name ends with .
sName = Mid(sName,2,xPos)
oSheet = ThisComponent.Sheets.getByName(sName)
oRange = oSheet.getcellrangebyname(rngname)
rtot=oRange.rows.count -1
dim a(rtot)
for j=0 to rtot
oCell=oRange.getcellbyposition(0,j)
a(j)=ocell.string
next
DialogLibraries.LoadLibrary( "Standard" )
oDialog1 = CreateUnoDialog( DialogLibraries.Standard.Dialog1 )
oControl = oDialog1.GetControl("ComboBox1") 'provided it already exists
oControl.additems(a(),0)
oDialog1.Execute() 'entries can be added afterwards also
'but in a separate sub
rngname="Jason" 'the name of the range (one column by unknown number of rows)
oNamedRange = ThisComponent.NamedRanges.getByName(rngname)
sName = oNamedRange.getContent() 'gives full address starting with $
xPos = InStr(1,sName,".") - 2 'sheet name ends with .
sName = Mid(sName,2,xPos)
oSheet = ThisComponent.Sheets.getByName(sName)
oRange = oSheet.getcellrangebyname(rngname)
rtot=oRange.rows.count -1
dim a(rtot)
for j=0 to rtot
oCell=oRange.getcellbyposition(0,j)
a(j)=ocell.string
next
DialogLibraries.LoadLibrary( "Standard" )
oDialog1 = CreateUnoDialog( DialogLibraries.Standard.Dialog1 )
oControl = oDialog1.GetControl("ComboBox1") 'provided it already exists
oControl.additems(a(),0)
oDialog1.Execute() 'entries can be added afterwards also
'but in a separate sub
Tuesday, January 31, 2006
Turn to sheet having range and select range
This is not the most elegant way of doing things, but it works for turning to the sheet containing "rngname" and then selecting the range. It doesn't turn to the desired sheet until the last line.
oDoc = ThisComponent
oRanges = oDoc.NamedRanges
oNamedRange = oRanges.getByName(rngname)
oAddr = oNamedRange.getContent()
xPos = InStr(1,oAddr,".")-2
oAddr = Mid(oAddr,2,xPos)
oCells = ThisComponent.Sheets.getByName(oAddr).getCellRangeByName(rngname)
ThisComponent.getCurrentController.select(oCells)
oDoc = ThisComponent
oRanges = oDoc.NamedRanges
oNamedRange = oRanges.getByName(rngname)
oAddr = oNamedRange.getContent()
xPos = InStr(1,oAddr,".")-2
oAddr = Mid(oAddr,2,xPos)
oCells = ThisComponent.Sheets.getByName(oAddr).getCellRangeByName(rngname)
ThisComponent.getCurrentController.select(oCells)
Columns before rows
In cell addresses, the column position comes before the row position. (Both start with 0.) So, I hope these are right,
oSheet.getCellByPosition(1,3)
is equivalent to
oSheet.getCellRangeByName("B4")
To get ranges:
oRange = ThisComponent.NamedRanges.getByName("Jason")
oRange = oSheet.getCellRangeByPosition(0,0,1,3)
oRange = oSheet.getCellRangeByName("a1:b3")
These are equivalent, provided Jason is a1:b3.
temp = oCell.getSpreadSheet().getName
temp2 = oCell.CellAddress.Column
temp3 = oCell.CellAddress.Row
get the name of the spreadsheet that oCell is on, the column number, and the row number.
temp = oRange.getSpreadSheet().getName
doesn't work.
oSheet = oDoc.Sheets.getByName("Brian")
oSheet = oDoc.Sheets.getByIndex(1)
are equivalent, provided the 2nd sheet is named Brian.
oSheet.getCellByPosition(1,3)
is equivalent to
oSheet.getCellRangeByName("B4")
To get ranges:
oRange = ThisComponent.NamedRanges.getByName("Jason")
oRange = oSheet.getCellRangeByPosition(0,0,1,3)
oRange = oSheet.getCellRangeByName("a1:b3")
These are equivalent, provided Jason is a1:b3.
temp = oCell.getSpreadSheet().getName
temp2 = oCell.CellAddress.Column
temp3 = oCell.CellAddress.Row
get the name of the spreadsheet that oCell is on, the column number, and the row number.
temp = oRange.getSpreadSheet().getName
doesn't work.
oSheet = oDoc.Sheets.getByName("Brian")
oSheet = oDoc.Sheets.getByIndex(1)
are equivalent, provided the 2nd sheet is named Brian.
Sunday, January 29, 2006
Subscribe to:
Posts (Atom)