[Solved] Writing custom Document Property fields
Posted: Wed Sep 18, 2013 11:44 pm
Hi I want to know how can I write custom variables/values into a document, and also extract them. I was able to find the latter, but I am still a bit confused about inserting them.
I guess it doesnt make much sense to do this since these are permanents and once written, there is no need to re-fill them out.
However I want this to be dynamic from a different datasource.
Having DocInfo also available through:
This will give me the name of the Author. What I am missing is how to modify and re-submit the value from Basic.
Or Master fileds are worked with:
I guess it doesnt make much sense to do this since these are permanents and once written, there is no need to re-fill them out.
However I want this to be dynamic from a different datasource.
Code: Select all
Sub GetMetaData
vDoc = ThisComponent
vInfo = vDoc.getDocumentInfo()
For i = 0 to vInfo.GetUserFieldCount() -1
sKey = vInfo.GetUserFieldName(i)
sVal = vInfo.GetUserFieldValue(i)
s = s & Chr$(13) & "(" & sKey & "," & sVal & ")"
Next i
MsgBox s, 0, "User Fields"
End SubCode: Select all
oPropValues() = ThisComponent.getDocumentInfo().getPropertyValues()
MsgBox oPropValues(0).Value
Or Master fileds are worked with:
Code: Select all
oDoc = thisComponent
objField = oDoc.createInstance("com.sun.star.text.TextField.User")
sName = "com.sun.star.text.FieldMaster.User." + strVarName