[Solved] Runtime error drawpage

Discuss the database features
Post Reply
ByteBlick
Posts: 11
Joined: Tue Jan 31, 2017 10:45 am

[Solved] Runtime error drawpage

Post by ByteBlick »

Hey mates,

i got a macro witch is working fine when i'm executing it manually. But this macro needs to be executed by an other macro from an other form. When i'm opening it from my macro i got a runtime error because "thisComponent.drawpage" seems to point on the wrong object. how i can fix it?

Code: Select all

Sub filter_subforms (project_id AS STRING)

REM set filter 	
ThisDatabaseDocument.FormDocuments.drawpage.forms.getByName("project_sub").filter  = "project_id = " + project_id
    
REM set default
thisComponent.drawpage.forms.getByName("project_sub").GetByName("project_sub_grid").GetByName("project_id").SetPropertyValue("EffectiveDefault", project_id)
thisComponent.drawpage.forms.getByName("project_sub").reload

End Sub
Greetings :)
Last edited by ByteBlick on Wed Feb 01, 2017 5:37 am, edited 1 time in total.
StarOffice 1.0 on Windows 3.11
User avatar
RoryOF
Moderator
Posts: 34610
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Runtime error drawpage

Post by RoryOF »

While I have only little knowledge of macros, I suspect thisComponent points to the originating file, not the target file. A diagnostic print statement, a breakpoint, or MRI should settle that. If my supposition is correct, you will have to replace thisComponent by a better identifier for the target file.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
ByteBlick
Posts: 11
Joined: Tue Jan 31, 2017 10:45 am

Re: Runtime error drawpage

Post by ByteBlick »

Thanks, but witch identifier is the right question. I try to use the MRI tool, but it seem to be outdated. :(
StarOffice 1.0 on Windows 3.11
F3K Total
Volunteer
Posts: 1038
Joined: Fri Dec 16, 2011 8:20 pm

Re: Runtime error drawpage

Post by F3K Total »

ByteBlick wrote:Thanks, but witch identifier is the right question. I try to use the MRI tool, but it seem to be outdated.
Your signature shows Open Office 2.4, which is outdated. MRI works fine with AOO 4.1.3
R
  • MMove 1.0.6
  • Extension for easy, exact positioning of shapes, pictures, controls, frames ...
  • my current system
  • Windows 10 AOO, LOLinux Mint AOO, LO
ByteBlick
Posts: 11
Joined: Tue Jan 31, 2017 10:45 am

Re: Runtime error drawpage

Post by ByteBlick »

I was forced to fill the field for registration, but now i was upgrading my real system specs. :lol:

Of course i'm using the newest OO-Version and i think there isn't a big difference between those constants on different versions.
StarOffice 1.0 on Windows 3.11
UnklDonald418
Volunteer
Posts: 1546
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Runtime error drawpage

Post by UnklDonald418 »

thisComponent, refers to the current (active) document.
With the MRI extension installed and enabled you should be able to inspect thisComponent if you include the following code in your macro

Code: Select all

 Globalscope.BasicLibraries.LoadLibrary( "MRILib" )
 oMRI = CreateUnoService( "mytools.Mri" )
oMRI.inspect thisComponent
An alternative is the Xray tool
http://berma.pagesperso-orange.fr/index2.html
Without one of those you will essentially be poking around in the dark. Chapter 12 of Andrew Pitonyak's book “OpenOffice.org Macros Explained” does show some code for enumerating the components of a Document.
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
ByteBlick
Posts: 11
Joined: Tue Jan 31, 2017 10:45 am

Re: Runtime error drawpage

Post by ByteBlick »

Thanks, the MRI - UNO Object Inspection Tool is running also on the newest version. The problem is that the tool is complex and is not telling me witch method i need. I think is a ordinary problem witch every base programmer already had solved once. The problem is maybe a relative link to the object or that i need to change my active document somehow. DrawPage isn't set. :crazy:

One formula contains a lot of information about my projects. There is also a macro witch is counting the children tables for related maintainer, documents, contacts and so. For those sub formulas isn't enough space in the edit project form, because i have to open a formula with a button. The button is opening a macro witch is opening the next formula and the next macro for the sub form.

I figured out an other way witch allows me to use my macro now. The macro of my first formula is setting a global with my project_id witch is available now in my sub forms. I'm not so happy with globals but it is a way witch works fine for me.

Thanks for trying to help!
StarOffice 1.0 on Windows 3.11
Post Reply