Can someone make this calc macro for me?

While I would like to know how to make macros, I don’t know how to make them, and I dont really have much time to learn the techniques given my task at hand right now. So errr… I’m gonna have to beg for help here… :slight_smile: What I want simple enough, so here goes…

Part I - Setting up the problem. Imagine entering calc and typing some text into a cell.

Part II - The Macro’s Functional Part - Right click the cell to get a drop down menu with an option to - 1.) create a new worksheet, and 2.) automatically create a hyperlink to jump to it when the link is clicked.

That’s it. That’s all I want it to do.

The only difficulty might seem to be naming the worksheet, but calc assigns default names as it is, and that is fine. The hyperlink itself should designate the relationship between the sheets.

I would program it (in python) myself, but I dont know the commands.

Any help VERY MUCH appreciated!

:slight_smile:

I’m sure everyone helping here will be happy to do your homework for you /s

I will not give a solution, but I will give two hints: the main object of the spreadsheet can be considered the SHEETS which you will receive using ThisComponent.getSheets(). This object has a method insertNewByName(). This is how the first part of the problem is solved. And a hyperlink can be formed in different ways. I prefer to choose a cell and use its setFormula() method to insert a formula with the HYPERLINK() function

Thank you JohnSUN. :slight_smile:

May I ask where you found those commands? There must be a list of them somewhere, or maybe tutorials.

I’d post some of the research I have done so far, but people are already razzing me for asking a serious question I need help with. And I dont want to get accused posting links to other sites others may not approve of for some reason or another.

My question seems pretty simple, and your clues are helpful. So I appreciate them. I dont mind connecting them, but I don’t know how.

Is there some kind of tutorial on how to make macros someone knows about? I keep running into blocks.

Maybe you all just want to take shots at me. I dont care. I still like the software. But it doesnt answer my question either. And - besides - straight forward, easy to find answers should benefit the community in turn, even if they might be somewhat redundant.

If this thread is getting out of hand, then I respectfully request the mod simply lock it

https://documentation.libreoffice.org/assets/Uploads/Documentation/en/GS5.1/HTML/GS5113-GettingStartedWithMacros.html

Maybe you all just want to take shots at me

If we really wanted this, then you could no longer write :slight_smile:

No, the reason is different. This is a small test, an exam. If you can overcome these difficulties, then perhaps you will grow further and become an exemplary programmer. Lately, the world has been filled with talentless people who call themselves programmers and their terrible products, which they call programs. These applications spoil the very idea of ​​a computer - instead of making life easier for a person, they load him with additional work. It is not right. I (and as far as I know - some other veteran volunteers) feel remorse - by giving correct and comprehensive answers, we did not encourage these programmer candidates to think and develop. The fact that the world has become worse is partly our fault. Therefore, lately I have been trying not to give answers, only hint and tips, sapienti sat.

There must be a list of them somewhere, or maybe tutorials.

Every bold word in my comment is a link to a documentation page. Most of these pages contain links to manuals that describe specific parts of the API.

I started with Pitonyak’s book. This does not need to be read in a row - search the Table of Contents for those parts that are similar in meaning to the parts of your current task and take the code from the same chapter. Then, when you have time, read everything from beginning to end.

OK, I will study the macro programming and the API functions instead of you.

:smiley:

You can list the properties, methods, and interfaces of the programming objects by an object inspection tool: MRI or the XrayTool. (I am using the XrayTool in my StarBasic macros.)

Otherwíse there are lists and description about the API object and functions, but those are huge stuffs.

https://extensions.libreoffice.org/en/extensions/show/mri-uno-object-inspection-tool

https://berma.pagesperso-orange.fr/index2.html

https://api.libreoffice.org/

https://api.libreoffice.org/examples/examples.html

https://api.libreoffice.org/docs/idl/ref/namespaces.html

https://www.pitonyak.org/oo.php

"I dont know where the LO commands to create a worksheet and create a hyperlink to it are. They must be in a list somewhere? "

You can load an empty Template file by this Basic macro lines (the API functions are same when you use python programming language. The code snippet is from the AOO/LO Forum):

https://forum.openoffice.org/en/forum/viewtopic.php?f=9&t=44142

Dim oNewWorkbook As Object
Dim Args(1) As new com.sun.star.beans.PropertyValue

Args(0).Name = "Hidden"
Args(0).Value = False
Args(1).Name = "MacroExecutionMode"
Args(1).Value = 4
       
oNewWorkbook = StarDesktop.loadComponentFromURL("private:factory/scalc", "_Blank", 0, Args)

:slight_smile:

The two basic techniques dont seem hard, but I dont know where the LO commands to create a worksheet and create a hyperlink to it are. They must be in a list somewhere?

I know enough to install a macro manually. I just dont know how to create the algorithm.

As for begging for help, I dont know how to ask it any other way… People on stackoverflow sometimes just request scripts outrightly, as there is always someone looking to learn and add to their portfolio of works, so I thought maybe an upstart might want to adopt this little script as a project…

It can’t hurt to ask anyway, and maybe simply having an example to follow would be a way to take my own learning and dev to the next step when I have more time…

In any case, I appreciate any assistance here… LO is a great suite… It’s the best I have found, I think, so thank you to the community for the good work they have done with it…

@wm777, please repost your “answer” as a comment, since it is not a solution to your question.

Thanks.