Error on "RunCmd.HideToolbar bcFormNavigation"

Creating and using forms
Post Reply
idachan
Posts: 44
Joined: Tue Jul 05, 2011 11:33 am

Error on "RunCmd.HideToolbar bcFormNavigation"

Post by idachan »

Hi!I have read post http://user.services.openoffice.org/en/ ... 13&t=31365 and I face error when running the macro.
I want to hide toolbar "Form Navigation",then I use RunCmd.HideToolbar bcFormNavigation
However,an error came out "BASIC runtime error. Object variable not set." and pointing to "RunCmd.HideToolbar bcFormNavigation".
How to deal with it?
The following is the macro:

Code: Select all

Sub NoBars ( oEvent as variant )
   If GlobalScope.BasicLibraries.hasByName("BaseTools") Then
      GlobalScope.BasicLibraries.LoadLibrary("BaseTools")
   End If   
   RunCmd.HideToolbar bcFormNavigation
End Sub
Thank you!
OpenOffice 3.0 on Windows XP
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: error on "RunCmd.HideToolbar bcFormNavigation"

Post by RPG »

Hello

what value does have: bcFormNavigation

Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
idachan
Posts: 44
Joined: Tue Jul 05, 2011 11:33 am

Re: error on "RunCmd.HideToolbar bcFormNavigation"

Post by idachan »

Hi~
I have read a pdf which is Base Tools description.
There is a part about hiding toolbar:
ShowToolbar | HideToolbar |
Show/hide a toolbar. See list of available toolbar names in the constants module.
RunCmd.ShowToolbar bcFormStatusBar
RunCmd.ShowToolbar bcFormDesign
RunCmd.HideToolbar bcFormControls

I want to hide a toolbar "Form Navigation".So I modified the command to RunCmd.HideToolbar bcFormNavigation...

Actually,even I keep the original one,error still exist@@
But I dunno how to tackle with it@@

Ida
OpenOffice 3.0 on Windows XP
QuazzieEvil
Volunteer
Posts: 283
Joined: Tue Dec 04, 2007 6:38 pm
Location: Houston, TX

Re: error on "RunCmd.HideToolbar bcFormNavigation"

Post by QuazzieEvil »

Did you load the Library.

The following code works for me:

Code: Select all

Sub From_WhenLoading(Event As Object)
	
	GlobalScope.BasicLibraries.LoadLibrary("BaseTools")
	RunCmd.HideToolbar bcFormsNavigationBar
	RunCmd.HideToolbar bcFormControls
	RunCmd.HideToolbar bcFormDesign
	RunCmd.HideToolbar bcFormMoreFormControls
	RunCmd.HideToolbar bcFormDrawBar

End Sub
ALSO, note that the navigation toolbar is actualy called bcFormsNavigationBar NOT bcFormNavigationBar. I took these names from config directory, and simply added the prefix bcForm for standarization's sake.. IN my Ubuntu Installation it is:

Code: Select all

roberto@phobos:/opt/openoffice.org3/basis-link/share$ ls config/soffice.cfg/modules/swriter/toolbar/
alignmentbar.xml      drawtextobjectbar.xml   formsfilterbar.xml      mediaobjectbar.xml    symbolshapes.xml
arrowshapes.xml       extrusionobjectbar.xml  formsnavigationbar.xml  moreformcontrols.xml  tableobjectbar.xml
basicshapes.xml       findbar.xml             formtextobjectbar.xml   numobjectbar.xml      textobjectbar.xml
bezierobjectbar.xml   flowchartshapes.xml     frameobjectbar.xml      oleobjectbar.xml      toolbar.xml
calloutshapes.xml     fontworkobjectbar.xml   fullscreenbar.xml       optimizetablebar.xml  viewerbar.xml
colorbar.xml          fontworkshapetype.xml   graffilterbar.xml       previewobjectbar.xml
drawbar.xml           formcontrols.xml        graphicobjectbar.xml    standardbar.xml
drawingobjectbar.xml  formdesign.xml          insertbar.xml           starshapes.xml
papijo
Posts: 90
Joined: Sat Nov 08, 2014 5:46 pm
Location: Brittany, West of France

Re: Error on "RunCmd.HideToolbar bcFormNavigation"

Post by papijo »

Hi QuazzieEvil,
Similarly to the OP in this thread I want to hide most form design toolbars from a base form when in "enter data" mode, whilst retaining them, of course, in Edit/Design mode.

May I say first I am quite surprised that this is not the default setting for OO forms? It would seems pretty obvious that the design toolbars need to be available when you are in design mode, but they get in the way and should be automatically hidden when one is entering data! As things are, the toolbars are displayed but inactive, does not look nice.

Anyway, I have installed the (excellent) BaseTools extension provided by Robert Benitez. I have created your Form_WhenLoading Macro in my document's macros. I have assigned it to a Form. It does work, but only once! That is to say if I open my Base document in AOO (or LO) and open the form document to which I have attached the Form_WhenLoading Macro, it does hide all toobars. But, if I add toolbars from the View|Toolbars menu, then quit that form, upon re-opening the form, the Toolbars are there, the macro does not work!
To make the macro work again it is not enough to close the document, one needs to completely exit AOO or LO and re-open it, etc. :?

What I really want, and from my perusing these forums and the Web I know I am not the only one is quite simply a way to hide design toolbars when I am in enter data mode and to show them when I am designing a form.

Can that be achieved? TIA.
LO: LibreOffice 6.4.0.3 (x64) on Windows 10 64bits. Split database HSQL 2.3.4.
User avatar
MikeytheMagnificent
Posts: 137
Joined: Fri Apr 11, 2008 12:06 am
Location: W. Yorks UK

Re: Error on "RunCmd.HideToolbar bcFormNavigation"

Post by MikeytheMagnificent »

The bars do go away (don't show) if you exit that form and reload it by double clicking the icon which Opens it in normal(data entry) mode.
Basically you started in geek mode so expect geeky things by default. You can always close the annoying (to you) bars and save your changes, but then you'll have the reverse annoyance next time you use edit mode, via edit>toolbars>form design . When in Geekland, as they say......
Many opportunities to add short Tutorials or faq's are missed

1. Must have obvious title to be found easily
2. Keep to objectives
3. Use very clear language
4. Difficult to get right
5. Rewards are few
papijo
Posts: 90
Joined: Sat Nov 08, 2014 5:46 pm
Location: Brittany, West of France

Re: Error on "RunCmd.HideToolbar bcFormNavigation"

Post by papijo »

@MikeytheMagnificent
Yes, I understand what you are saying. However, I maintain my point of view that it would be more user-friendly for the software "to hide design toolbars when you are in enter data mode and to show them when designing a form".
LO: LibreOffice 6.4.0.3 (x64) on Windows 10 64bits. Split database HSQL 2.3.4.
User avatar
MikeytheMagnificent
Posts: 137
Joined: Fri Apr 11, 2008 12:06 am
Location: W. Yorks UK

Re: Error on "RunCmd.HideToolbar bcFormNavigation"

Post by MikeytheMagnificent »

Which is exactly what happens if you do it the way I said as opposed to simply pressing the second icon on the design or controls toolbar to toggle modes. the form navbar does the same disappearing act (provided you have it set, moreover how are you going to get back to design mode if all the toolbars have been hidden in that semi-datamode other than by starting back and reopening anyway in whichever mode! No commandline or macro or button-stuff required
Many opportunities to add short Tutorials or faq's are missed

1. Must have obvious title to be found easily
2. Keep to objectives
3. Use very clear language
4. Difficult to get right
5. Rewards are few
User avatar
MikeytheMagnificent
Posts: 137
Joined: Fri Apr 11, 2008 12:06 am
Location: W. Yorks UK

Re: Error on "RunCmd.HideToolbar bcFormNavigation"

Post by MikeytheMagnificent »

Unless of course you're in the middle of a genuine data session and need to keep toggling the navbar on/off for some good reason, but thats nothing to do with edit mode
Many opportunities to add short Tutorials or faq's are missed

1. Must have obvious title to be found easily
2. Keep to objectives
3. Use very clear language
4. Difficult to get right
5. Rewards are few
Fensox
Posts: 5
Joined: Tue Dec 30, 2014 5:55 pm

Re: Error on "RunCmd.HideToolbar bcFormNavigation"

Post by Fensox »

papijo, did you ever solve the "only works once problem", where you have to shutdown the entire application to make it work again if you close the form?

Can anyone help please? I use the basetools ApplyFilter method and it works wonderfully on a form I created. If I exit that form to go do something else, print a report, etc., and then go back to the form, it will not work again. I have to close OpenOffice Base completely and re-open it. My function is below. Any help would be greatly appreciated, thank you. Just as an FYI, the basetools extension is loaded on the forms OnLoad event. Thinking that was the problem I tried doing it within the function below but that didn't make any difference so I put it back in the forms OnLoad event. Thanks in advance for any help.

Code: Select all

' Filter the records based on the work order number entered into the work order text box
Sub findWO
	Dim frmJob As Object
	Dim strWO As String
	Dim strFilter as String
	
	' build the string to send to the filter
	frmJob = ThisComponent.DrawPage.Forms.getbyindex(0)
	strWO = frmJob.getByName("txtFindWO").Text
	strFilter = "jobWorkOrderNumber='" & strWO & "'"
	
	' apply the filter using the BaseTools extension command
	RunCmd.FindRecord(strWO,bcMatchStart,False,10,bcFirstRecord,bcForward)
End Sub
OpenOffice 4.1.1
Windows 8.1 Pro 64-Bit
Fensox
Posts: 5
Joined: Tue Dec 30, 2014 5:55 pm

Re: Error on "RunCmd.HideToolbar bcFormNavigation"

Post by Fensox »

Nobody?
OpenOffice 4.1.1
Windows 8.1 Pro 64-Bit
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Error on "RunCmd.HideToolbar bcFormNavigation"

Post by RPG »

Hello

It is possile that basetools does not know what is the active form or you have a diferent idea then the basetools. As far I understand Basetools MeModel stands for the dataform. When you do some testing then it is maybe possible to knew if memodel is point to the good form.

You can also pass more parameters to the function. If you not pass a formname then it is used MeModel. When you pass a formname then it is doing some searching.
You can do some testing and do: print MeModel.name.

Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Fensox
Posts: 5
Joined: Tue Dec 30, 2014 5:55 pm

Re: Error on "RunCmd.HideToolbar bcFormNavigation"

Post by Fensox »

Thank you, I will try that and see if I can repoint it if it isn't where it should be. I appreciate the response!
OpenOffice 4.1.1
Windows 8.1 Pro 64-Bit
Fensox
Posts: 5
Joined: Tue Dec 30, 2014 5:55 pm

Re: Error on "RunCmd.HideToolbar bcFormNavigation"

Post by Fensox »

Unfortunately the MeModel IS pointing towards the correct form. So that isn't it.... This is a real pain of a problem.
OpenOffice 4.1.1
Windows 8.1 Pro 64-Bit
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Error on "RunCmd.HideToolbar bcFormNavigation"

Post by RPG »

Hello

Maybe Basetool does not know exact which object you want process. I think you have to init some more variables of the basetools. This must be done with calling some sub of functions of the Basetools. I think when you use the basetools then use as much of the basetools as can. I have change a little in the sub. I suppose you start the sub with an event from a button. This button must be in the data-form of your document. OpenOffice and also the basetool use heavy events.
It is good to use own variables but I have the idea: when you close the form document then all the variables must be init again when you reopen the form-document. I think this is true for your own variables but also for the variables of the Basetools. The Basetools init them self when you do open a Document, with a help of the baseools, or other things. In other words: When you want use the Basetools then use it heavy.

The programminng idea behind the Basetools is very close to the API.

FindRecord
It is me not so clear why you want use this function? This function is very slow there it process all data by BASIC. When you have a big database then I think it is better to work with filter your database. You can easy switch between filtered mode and not filtered mode.

Romke

Modified code

Code: Select all

Sub findWO(oEvent)
   Dim frmJob As Object
   Dim strWO As String
   Dim strFilter as String
   call forms.MeModel(oEvent) ' I use the word call then I knew I call a sub
   ' build the string to send to the filter
   'frmJob = ThisComponent.DrawPage.Forms.getbyindex(0)
   strWO = MeModel.getByName("txtFindWO").Text
   strFilter = "jobWorkOrderNumber='" & strWO & "'"
   'It is me not clear for what reason you use strFilter
   ' apply the filter using the BaseTools extension command
   RunCmd.FindRecord(strWO,bcMatchStart,False,10,bcFirstRecord,bcForward)
End Sub
A little example

Code: Select all

sub knopzien(oevent)
' This shows only how to use an event of a button.
dim oDataForm 
oDataForm=forms.memodel(oevent)
print oDataForm.name
end sub
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Fensox
Posts: 5
Joined: Tue Dec 30, 2014 5:55 pm

Re: Error on "RunCmd.HideToolbar bcFormNavigation"

Post by Fensox »

Thank you, I will try the filter and un-filter and see what happens. You are correct, the FindRecord function is s l o w.
OpenOffice 4.1.1
Windows 8.1 Pro 64-Bit
Post Reply