-writer macro- syntax help for beginner

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
fritzb
Posts: 3
Joined: Fri Nov 27, 2009 1:39 am

-writer macro- syntax help for beginner

Post by fritzb »

I am trying to make a macro that would fill in a calendar with both text and symbols. Since this is the first time I have done this I need a little help since I am a beginner trying my best to understand it all.
Once the cursor is positioned on the first day of the month, I recorded a macro to put the dates in the first column of each cell of the table. No problem there. Now I am trying to go from a point just after the date to the ending date filling in the following; Here is the only way I could figure it out; and in order to place a symbol, before starting on the 'record macro' I got the Character Map, went to wingdings, found the symbol and copied it to the clipboard.

Code: Select all

sub RxDateswhattotake

rem define variables
dim document   as object
dim dispatcher as object

document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())

dim args3(4) as new com.sun.star.beans.PropertyValue
args3(0).Name = "CharFontName.StyleName"
args3(0).Value = ""
args3(1).Name = "CharFontName.Pitch"
args3(1).Value = 2
args3(2).Name = "CharFontName.CharSet"
args3(2).Value = 10
args3(3).Name = "CharFontName.Family"
args3(3).Value = 3
args3(4).Name = "CharFontName.FamilyName"
args3(4).Value = "Webdings"

dispatcher.executeDispatch(document, ".uno:CharFontName", "", 0, args3())

' and here is where it uses the wingding that was copied.
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
'pasted four symbols (In the first column; wingdings Character OxA8 or Chr$(168)) Here I could use the help.

Question: Is there any way to state the name and character num that could be used in place of the disorderly way I have used here, ie. copy to the clipboard and paste? In other words gather the Font Name, the Chr num, and the font size and then put it into some (variable?) waiting to be used?

I attached a pic of the way it should look
calendarSection.png
calendarSection.png (9.99 KiB) Viewed 848 times
Thanks for reading

fb
Last edited by robleyd on Sun Nov 04, 2018 11:07 pm, edited 1 time in total.
Reason: Added Code tags
OpenOffice 3.1 on Windows XP
JeJe
Volunteer
Posts: 2784
Joined: Wed Mar 09, 2016 2:40 pm

Re: -writer macro- syntax help for beginner

Post by JeJe »

Code: Select all


dim oVC
oVC = thiscomponent.currentcontroller.viewcursor

OVC.charheight = 10

for i = 0 to 4
oVC.collapsetoend
OVC.charfontName = "Webdings"
oVC.string =  Chr$(168)
oVC.collapsetoend
oVC.charfontname = "Times New Roman"
oVC.string = " blah blah"
oVC.collapsetoend
otext =thiscomponent.text
oText.insertControlCharacter(oVC,0,false)
next

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply