[Solved] "Writing Macros for Dummies" tutorials/docs?
[Solved] "Writing Macros for Dummies" tutorials/docs?
Hi. I'm trying to write some Basic macros and am looking for some documentation and/or examples of simple Basic macros. I've read the Apache documentation, but am finding it difficult to navigate the modules/interfaces to create objects correctly. I observe that the examples provided seem not to work. For example, if I try to run code like this:
dim Doc as Object
dim Sheet as Object
Doc = ThisComponent
Sheet = Doc.Sheets.getByName("Whatever")
... I get a runtime error "Property or Methods Not Found: Sheets". My guess is that lines are omitted to simplify the documentation, but I need a few complete examples.
Can someone point me in a helpful direction?
Thanks in advance.
dim Doc as Object
dim Sheet as Object
Doc = ThisComponent
Sheet = Doc.Sheets.getByName("Whatever")
... I get a runtime error "Property or Methods Not Found: Sheets". My guess is that lines are omitted to simplify the documentation, but I need a few complete examples.
Can someone point me in a helpful direction?
Thanks in advance.
Last edited by Fafhrd on Tue Oct 04, 2022 9:12 pm, edited 2 times in total.
Fafhrd
OpenOffice 4.1.13 on Windows 10
OpenOffice 4.1.13 on Windows 10
Re: "Writing Macros for Dummies" tutorials/docs?
Check the documents at Andrew Pitonyak's web site: OpenOffice.org Macros Explained and the English Macro Document
However, the macro code you posted should work if run from a Calc document that has a sheet named Whatever. How are you using the code?
However, the macro code you posted should work if run from a Calc document that has a sheet named Whatever. How are you using the code?
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: "Writing Macros for Dummies" tutorials/docs?
Provided the current component is a spreadsheet document with a sheet named "Whatever" your code should work and not give an error.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: "Writing Macros for Dummies" tutorials/docs?
Here is a working example
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: "Writing Macros for Dummies" tutorials/docs?
Dummies may be able to write VBA code for Excel whereas writing StarBasic for UNO is completely out of reach. Forget it, Dummy.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: "Writing Macros for Dummies" tutorials/docs?
The best source for simple macros is possibly here - there's often someone's had the same problem and a search will find it.
You might these tools invaluable:
https://extensions.openoffice.org/en/pr ... -ide-tools
https://extensions.openoffice.org/en/pr ... ction-tool
You might these tools invaluable:
https://extensions.openoffice.org/en/pr ... -ide-tools
https://extensions.openoffice.org/en/pr ... ction-tool
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: "Writing Macros for Dummies" tutorials/docs?
' Begin moduleFJCC wrote: ↑Mon Oct 03, 2022 6:41 am Check the documents at Andrew Pitonyak's web site: OpenOffice.org Macros Explained and the English Macro Document
However, the macro code you posted should work if run from a Calc document that has a sheet named Whatever. How are you using the code?
dim Doc as Object
dim Sheet as Object
sub Main
' Need to call this function to enable "Private" variables/objects.
CompatibilityMode(True)
' Initialize objects and variables.
Init
...
end sub
sub Init
Doc = ThisComponent
If Doc.Sheets.hasByName("Whatever") Then
Sheet = Doc.Sheets.getByName("Whatever")
Else
exit sub
End If
...
end sub
Fafhrd
OpenOffice 4.1.13 on Windows 10
OpenOffice 4.1.13 on Windows 10
Re: "Writing Macros for Dummies" tutorials/docs?
Never mind, figured it out. I had my macro defined in an (otherwise empty) separate doc, opened that doc from another, and ran the macro. Context is still that of the empty doc, apparently.
Fafhrd
OpenOffice 4.1.13 on Windows 10
OpenOffice 4.1.13 on Windows 10
Re: "Writing Macros for Dummies" tutorials/docs?
Please use the CODE tag for formatting the macro code lista in this forum.
Code: Select all
Begin module
dim Doc as Object
dim Sheet as Object
sub Main
' Need to call this function to enable "Private" variables/objects.
CompatibilityMode(True)
' Initialize objects and variables.
Init
...
end sub
sub Init
Doc = ThisComponent
If Doc.Sheets.hasByName("Whatever") Then
Sheet = Doc.Sheets.getByName("Whatever")
Else
exit sub
End If
...
end sub
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: "Writing Macros for Dummies" tutorials/docs?
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Re: "Writing Macros for Dummies" tutorials/docs?
Thanks everyone, I'm good (for now).
Fafhrd
OpenOffice 4.1.13 on Windows 10
OpenOffice 4.1.13 on Windows 10
Re: "Writing Macros for Dummies" tutorials/docs?
Zizi64 wrote: ↑Tue Oct 04, 2022 6:44 am Please use the CODE tag for formatting the macro code list in this forum.
Code: Select all
Begin module dim Doc as Object dim Sheet as Object sub Main ' Need to call this function to enable "Private" variables/objects. CompatibilityMode(True) ' Initialize objects and variables. Init ... end sub sub Init Doc = ThisComponent If Doc.Sheets.hasByName("Whatever") Then Sheet = Doc.Sheets.getByName("Whatever") Else exit sub End If ... end sub
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.