Ask Your Question
0

macro to get & set the document custom properties [closed]

asked 2015-10-21 11:52:40 +0200

jay Arr gravatar image

updated 2016-03-16 13:28:09 +0200

Alex Kemp gravatar image

Using LO Version: 5.0.2.2 on iMac with OSX 10.10.5

I have a need to get and set these document custom properties:

image description

I used the record a macro facility whist changing displayCopyright from Yes to No. This is the macro code I got:

 REM  *****  BASIC  *****


sub Main
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(9) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Properties.UseUserData"
args1(0).Value = true
args1(1).Name = "Properties.DeleteUserData"
args1(1).Value = false
args1(2).Name = "Properties.Title"
args1(2).Value = "SecretaryBird template"
args1(3).Name = "Properties.Subject"
args1(3).Value = ""
args1(4).Name = "Properties.KeyWords"
args1(4).Value = ""
args1(5).Name = "Properties.Description"
args1(5).Value = ""
args1(6).Name = "Properties.AutoReload"
args1(6).Value = false
args1(7).Name = "Properties.AutoReloadTime"
args1(7).Value = 0
args1(8).Name = "Properties.AutoReloadURL"
args1(8).Value = ""
args1(9).Name = "Properties.AutoReloadFrame"
args1(9).Value = ""

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


end sub

Which is NOT a lot of help!

Can anyone give me any pointers/suggestions?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-03-16 13:28:22.185559

1 Answer

Sort by » oldest newest most voted
0

answered 2015-10-21 13:28:45 +0200

jay Arr gravatar image

updated 2015-10-21 13:29:55 +0200

Thanks to Andrew Pitonyak's document

AndrewMacro.odt

see his website here

I've found the solution:

sub getsetDocCustomProperties
  Dim oProps    as object
  Dim oDocProps as object
  dim s as string

oDocProps = ThisComponent.getDocumentProperties()
oProps = oDocProps.UserDefinedProperties
 s = s & "Classification = " & oProps.[Classification] & CHR$(10) & _
      "Poetic Form = " & oProps.[Poetic Form] & CHR$(10) & _
      "Subclassification = " & oProps.[Subclassification] & CHR$(10) & _
      "Version number = " & oProps.[Version number]& CHR$(10) & _
      "Version suffix = " & oProps.[Version suffix]& CHR$(10) & _
      "displayCopyright = " & oProps.[displayCopyright]& CHR$(10) & _
      "displayLogo = " & oProps.[displayLogo]& CHR$(10) & _
     "displayModificationTimeDate = " & oProps.[displayModificationTimeDate]& CHR$(10) & _
     "displayPageNumber = " & oProps.[displayPageNumber]& CHR$(10) & _
     "displayVersion = " & oProps.[displayVersion]
  MsgBox s
  ' try changing
   oProps.[Classification]="SCIENCE"

end sub
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-10-21 11:52:40 +0200

Seen: 1,112 times

Last updated: Oct 21 '15