[Solved] How to insert personalized fields with hotkeys?

Discuss the word processor
Post Reply
JRMAS
Posts: 3
Joined: Tue Aug 10, 2021 1:53 pm

[Solved] How to insert personalized fields with hotkeys?

Post by JRMAS »

I use a hotkey to put the date, but I need it with the dd/mm/yyyy format, instead of dd/mm/yy.

Also, I also need to make it in a way that there is no grey background in the field. I know that the background will not appear on a PDF or printed, but I need it without the grey shade for EVERYONE, even for people who open the document with another computer.
Last edited by JRMAS on Tue Aug 10, 2021 4:15 pm, edited 1 time in total.
OpenOffice 4.1 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to insert personalized fields with hotkeys?

Post by Villeroy »

You are not using OOo 3.1 on WIndows 7, do you?
Last edited by Villeroy on Tue Aug 10, 2021 2:32 pm, edited 2 times in total.
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
JRMAS
Posts: 3
Joined: Tue Aug 10, 2021 1:53 pm

Re: How to insert personalized fields with hotkeys?

Post by JRMAS »

Villeroy wrote:You are not using OOo 3.1 on WIndows 7, do you?
Sorry, 4.1
OpenOffice 4.1 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to insert personalized fields with hotkeys?

Post by Villeroy »

Anyway, see chapter 3 on "AutoText" in the Writer guide: https://wiki.openoffice.org/wiki/Docume ... e_Chapters
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
JeJe
Volunteer
Posts: 2784
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to insert personalized fields with hotkeys?

Post by JeJe »

If its a fixed date, does it have to be a field? You can insert the date as text in your chosen format with a simple macro - and obviously there will be no field shading.

Code: Select all

Sub insertDate
vc =thiscomponent.currentcontroller.viewcursor
vc.string = format(date,"dd/mm/yyyy")
vc.collapsetoend
End Sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
JeJe
Volunteer
Posts: 2784
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to insert personalized fields with hotkeys?

Post by JeJe »

The macro recorder gives the following macro for inserting a date field in the format you want.

Code: Select all


sub insertDateField
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(5) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Type"
args1(0).Value = 0
args1(1).Name = "SubType"
args1(1).Value = 0
args1(2).Name = "Name"
args1(2).Value = ""
args1(3).Name = "Content"
args1(3).Value = "0"
args1(4).Name = "Format"
args1(4).Value = 8036
args1(5).Name = "Separator"
args1(5).Value = " "

dispatcher.executeDispatch(document, ".uno:InsertField", "", 0, args1())


end sub

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
JeJe
Volunteer
Posts: 2784
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to insert personalized fields with hotkeys?

Post by JeJe »

You can hide the grey field shading by setting the background color to white (assuming a white page background).
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
JRMAS
Posts: 3
Joined: Tue Aug 10, 2021 1:53 pm

Re: How to insert personalized fields with hotkeys?

Post by JRMAS »

Thanks to everyone! It worked!
OpenOffice 4.1 on Windows 7
Post Reply