I am trying to create a Writer menu item that has a variety of .ott files to choose from. I am trying this way because I want to open templates only using keyboard shortcuts. The standard templates interface doesn’t provide a way to use keyboard shortcuts but menus do.
I created macros that will open documents, created a new menu item, added my macros to the list, and gave them all shortcut keys using the tilde ~ in front of the letter I want to use.
Unfortunately, the code I use opens the template as new okay, but the macro in the document won’t run. If I open the template directly from a file manager it runs with the macro perfectly. I tried a variety of my templates that have macros that run on opening, but none of them work either.
Here is my macro code, I tried simpler versions that worked just the same, but this one includes the property to run the macro:
sub Memo
FileName = "F:\Home\Libre\Forms\memo.ott"
Dim url
url = ConvertToURL(FileName)
Dim FileProperties(1) As New com.sun.star.beans.PropertyValue
FileProperties(0).Name = "AsTemplate"
FileProperties(0).Value = True
FileProperties(1).Name = "MacroExecMode"
FileProperties(1).Value = 4
StarDesktop.loadComponentFromURL(url,"_blank",0,FileProperties())
End Sub
As I said, that opened the file, but the file was opened in some way that ignored the macro that is supposed to run on the event of “New Document”. I assume it is actually inserting the contents of the file into a new document instead of actually opening the ott file. But I could be all wrong.
Here’s what the menu item looks like:
I have spent over 20 hours trying to make this work. Lots of research, learned a lot, but unsuccessful in my effort. Hope you can help, thanks in advance for even reading this.