Macros x Base

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
lazykitty
Posts: 1
Joined: Mon Sep 09, 2019 9:07 pm

Macros x Base

Post by lazykitty »

Hello,

I am trying to use base... I am pretty new to OpenOffice, so I know that there is a lot that I need to learn but at this point I don't think I am looking for material at the right place so if anyone could shine a light on the following:
1. I am creating a database, and my goal was to have my form able to recall information from the previous record and also able to overwrite information by prompting an input box (through a push button)...
Since base is kinda straight forward it was easy to use wizard to set up my table and getting to view mode to edit stuff. My first step was to create the push button and set the execute event to a macro which so far is

Code: Select all

option explicit
sub changeemployee 

dim operator$
operator =  inputbox ("Insert your initials","") 'creating dialog box so employee can change initials
I tried to assign operator.value = txtInitials.value, since that's the fieldbox name but unsurprisingly it does not work. I realized that I did not know how to "call" a field so I tried to search for it and I came across a few posts, and the library manual so I assumed I could use something like to at least get used to the system:

Code: Select all

sub learning_how ()
dim oDoc as object
dim oDrawpage as object
dim oform as object
oDoc = thisComponent
oDrawpage = oDoc.drawpage 
oform = oDoc.forms.getByName("SCAN UDI")
oform.table("initials").value=operator.value 'where initials is the name of my column in the table
end sub 
But I get the error "Property or method not found: drawpage", initially I believe it might be a problem with my library not being registered but it is so I have no idea why I get this error... I have no idea if my initial idea could be valid here either, to just call that field and assign a value to it...
I also realized that if I want to copy or recall information from my previous record I will need to know how to call that information in particular, but I am not familiar with all the inputs and weird line calls (aka sun.bean.whatever whatever or $c10 for jumping lines). I don't mind have to learn all this material, but so far I can't find a lot of information that can be related to base specifically. I found a bible regarding macros by Andrew Pitonyak which did teach me a few things, but I think at this point my problem might be the language itself, so if anyone has a good tutorial on basic that is not for calc please send it my way

I believe I absolutely need to use macro for this but if I am wrong I will take the easier way

2. I have a serial number that is a autofil field, and I was wondering if instead of displaying "autofill" I could have it display the actual number?

Either way, I appreciate any help.
Thank you
OpenOffice 4.1.6 on Windows
UnklDonald418
Volunteer
Posts: 1547
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Macros x Base

Post by UnklDonald418 »

But I get the error "Property or method not found: drawpage"
While Star Basic is not case sensitive the OO API is, try

Code: Select all

oDrawpage = oDoc.DrawPage
It is best to learn about and take advantage of all the capabilities of Base and Base Forms, and avoid macro programming as much as possible. As you are seeing, macro code is difficult to write and easy to break. The code is often form specific, i.e. make a small change to the form and the macro might stop working.
I believe I absolutely need to use macro for this but if I am wrong I will take the easier way
Based on the information you provided it would be difficult for anyone here to give specific recommendations as to how to avoid a macro for your situation.
Near the top of the Base forum page is a link to Base Tutorials where you can find helpful information and near the top of that page is a link to Database Examples where you will find more useful information.
I have a serial number that is a autofil field, and I was wondering if instead of displaying "autofill" I could have it display the actual number?
When you see <AutoField> on a row/record that indicates that row has not been saved into the underlying database table so the value is unknown. It isn't until the row is saved that the database engine assigns a value to that field.

If you are going to do macro programming in OO you will need to learn to use an object inspection tool.
[Tutorial] Introduction into object inspection with MRI
For a good book on macro programming in Base get "Database Programming with OpenOffice.org Base & Basic" by Roberto Benitez
The source code for all his macros can be downloaded from
http://www.baseprogramming.com/resources.html
But to understand them you will probably need to purchase the book.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Post Reply