I am trying to create a macro that will enable me to refresh the contents of a listbox when the listbox receives focus. I found some macros in other posts, but I can't get them to work, and I'm not sure what I'm doing wrong. I have tried typing them in the window that opens when you click the new button in the macro organiser, and then clicking the run button to test their operation. I have absolutely no experience with macros, so everything I'm using is as-is unless it's obvious which bits have to change.
I have tried the following:
REM ***** BASIC *****
Sub RefreshListbox (oEv as object)
oEv.source.model.Refresh
rem ... this will refresh the listbox if the underlying table has changed
End Sub
To which I receive an error saying "BASIC runtime error. Argument is not optional." and it highlights the "oEv.source.model.Refresh" section.
REM ***** BASIC *****
Sub RefreshListbox
dim oForm as object
oForm = thisComponent.Parent.FormDocuments
if oForm.HasByName( "MainEntryForm-CatDetails") then
oForm = oForm.getByName( "MainEntryForm-CatDetails")
if not IsNull(oForm.Component) then
oForm = oForm.Component.DrawPage.Forms.getByName( "MainForm")
oForm.getByName("ListBox").refresh()
End if
End if
End Sub
This one just doesn't run - doesn't come up with any messages to say it doesn't work, it just doesn't say anything at all.
REM ***** BASIC *****
Sub RefreshListbox
oEv.source.model.parent.GetByName ("ListBox")
oEv.source.model.parent.GetByName ("ListBox").Refresh
End Sub
I get the same "BASIC runtime error. Object variable not set." message and it highlights "oEv.souce.model.parent.GetByName ("ListBox")"
Any help much appreciated.
[Solved] Refresh listbox macro
[Solved] Refresh listbox macro
Last edited by Hezza1506 on Fri Jan 30, 2009 8:04 pm, edited 1 time in total.
OOo 3.0.X on MS Windows Vista
Re: Refresh listbox macro
In answer to one of my other posts, someone explained how to create a macro. It turns out all that I was doing wrong was trying to build the macro in the wrong place. Doh!
I've now got the refresh mechanism working using the first, and simplest, option:
Sub RefreshListbox (oEv as object)
oEv.source.model.Refresh
rem ... this will refresh the listbox if the underlying table has changed
End Sub
I've now got the refresh mechanism working using the first, and simplest, option:
Sub RefreshListbox (oEv as object)
oEv.source.model.Refresh
rem ... this will refresh the listbox if the underlying table has changed
End Sub
OOo 3.0.X on MS Windows Vista