Errors in Wiki Examples?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
slc193
Posts: 11
Joined: Sat Mar 15, 2008 5:08 pm

Errors in Wiki Examples?

Post by slc193 »

So I am copying code off of the wiki pages, trying to learn and understand it. I am looking at the page:

http://wiki.services.openoffice.org/wik ... With_Forms

and copying the following code to my BASIC editor and trying to run it.

Sub OpenInvoice
Dim Doc As Object
Dim DrawPage As Object
Dim Form As Object

Doc = StarDesktop.CurrentComponent
DrawPage = Doc.DrawPage
Form = DrawPage.Forms.GetByIndex(0)
End Sub

But I get the following error:

"BASIC runtime error. Property or method not found." while it highlights line 7 of the code above.

Any help in understanding this? I am just starting to learn BASIC and not seeing where the error is. And why would faulty code be posted in the wiki? Ot what am I not quite understanding?
User avatar
Hagar Delest
Moderator
Posts: 32658
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Errors in Wiki Examples?

Post by Hagar Delest »

I think that this is only a snippet, a part of a longer code just to show what's the beginning to do a specific task. Have you read the context? Create a blank text document in Writer, add a form control and run the macro, there is no error code. Note that the code in the wiki has not the EndSub command, meaning that it's not a complete code.

If you want to start with macros, dig this forum, there are links to material like in that thread: [Solved] Writing Macros - Where Do I Start?

Thanks to add '[Solved]' at beginning of your first post title (edit button) if your issue has been fixed.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Post Reply