This is huge. Thanks to TerryJ on the [email protected] alias for pointing the way.
So you're an IT director. You want to make things easy for your users (and thus easy for your team so they need to answer fewer questions). One way to make things very easy and simple for your users is to create templates.
- Create a template that has no page number on the first page and a page number, starting at 1 or 2, on the 2nd page. (A user could create this but it involves understanding styles and is just way more difficult than it needs to be.)
- Create a template that has a watermark background like Confidential.
- Create a template that has whatever characteristics are needed for a department's tasks.
Now, you could create a template and just set it as the default template so that users get that template when they choose File > New. But if you have multiple documents they need to make, you probably don't want to do that. Or you can do that, but you have more than one template you want to offer.
You could just put your templates in a nice centralized location for your users. However, some users don't view it as all that convenient or obvious to choose File > New > Templates and Documents, the pick the right category and the right template.
Here's how to make it easy, and thus likely, for users to use the templates you provide for them, and thus for them to not even enounter problems, or encounter tasks that are harder than they need to be.
Make a menu and attach templates to menu items on that menu.
Now, this means more up-front work for you, but then it's done.
A) Make your templates and put them in a central network location. Be sure they're in template format, not document format.
B. Create a new menu.
Choose Tools > Customize, click the Menu tab, click New, then name it and click OK.
C. Now you just need to add menu items that point to the templates.
First, create the macro.
1. Choose Tools > Macros > Organize Macros > OpenOffice.org Basic.
2. This window will appear. The macro I already created is listed there. In this example I'll create another one that does the same thing.
3. In the Macro Name field, type the macro name like OpenTemplate.
4. Click New.
5. What you now see in the macro editing area will depend on what was there last. I'm not incredibly familiar with the macro window but I know that what I did worked ;> so you should be able to follow these directions successfully.
Regardless of what else is in there, you want to have the following. Find the part that says
Sub macroname
End sub
and put your macro in the middle. Leave all the other macros that are there.
6. Now you want to write the following macro. There are variations here but this is what I did that worked.
I show an example first, then syntax.
Example
Sub OpenTemplate
Dim sUrl as String
sUrl = "file:///C:/openofficemacros/sampletemplate.ott" ' note you must use url format
If NOT FileExists( sUrl ) Then : Msgbox( "No file named " & sUrl ) : Exit sub : End If
StarDesktop.loadComponentFromURL( sUrl, "_blank", 0, Array() )
End Sub
Now the syntax
Sub name of macro
Dim sUrl as String
sUrl = "file:///path to file you want to open"' ' note you must use url format
If NOT FileExists( sUrl ) Then : Msgbox( "No file named " & sUrl ) : Exit sub : End If
StarDesktop.loadComponentFromURL( sUrl, "_blank", 0, Array() )
End Sub
7. Click the Save icon and close the macro.
8. If you choose Tools > Macros > Organize Macros > OpenOffice.org Basic again, you'll see the macro name. Here the original one I wrote and the one I added for this example are both shown.
9. From here, you can either:
Select the macro to use and click Assign
OR
Close the window, then choose Tools > Customize, and in the Menus tab, select the menu you created.
10. Click Add next to the empty list for menu items
11. In the window that appears, expand the Macros category at the bottom, and select the macro you wrote.
12. Click Add.
13. Close the window.
14. Select the item, click and hold down on Modify.
15. In the window that appears, rename the item however you like and click OK.
16. Click OK in the Customize window.
17. Now choose the menu and the menu item.
18. The document you created appears. If you created it in template format, then it will be an untitled copy of the document.
D. Copy the configuration to other computers.
1. Copy the macro to the same location on other computers.
2. Copy the configuration file where the menu and menu items are stored to the same location on other computers. It's called menubar.xml; there are several depending on what the menu is for. Here's where it is on Windows for a Writer menu; for Calc it would be scalc\menubar\menubar.xml, and so on.
<openofficeinstalldir>\soffice.cfg\modules\swriter\menubar\menubar.xml
Here's what the content looks like in the menubar.xml file.
<menu:menu menu:id="vnd.openoffice.org:CustomMenu1" menu:label="Use These Templates">
<menu:menupopup>
<menu:menuitem menu:id="vnd.sun.star.script:Standard.Module1.OpenTemplate?language=Basic&location=application" menu:helpid="vnd.sun.star.script:Standard.Module1.OpenTemplate?language=Basic&location=application" menu:label="Use this for meeting minutes"/>
</menu:menupopup>
</menu:menu>
See this link for the original explanation.