Membru care solicită informaţii
I need to add dymanic watermark in the document. I get watermark image url in custome properties of a MS Word document. I am sure this is development question, please advise?
This is what i am thinking, but dont know how to do it..
1) have a hidden field in document which gets updated on open
2) Some mactro which read this hidden field and add the watermarking in the document like..in our case it will be http link to the watermark image or it could be the text as well..
Please advise if it is possible, or how to do it or if there is other easy way to do that?
I used Word's macro recorder to record inserting a Watermark into the document. I then edited the code to make it more "streamlined". The result is below.
I don't have anything in there about a "hidden field" as I'm not sure exactly what it is you want. You need to provide more information about how this part should work. What populates this information, if it's hidden?
Sub InsertWatermarkPicture Dim shp As word.Shape Dim rngHeader As word.Range Set shp = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).shapes.AddPicture(FileName:= _ "C:\Users\UserName\Pictures\Avatar.jpg", LinkToFile:=False, _ SaveWithDocument:=True) shp.Name = "WordPictureWatermark17165070" shp.PictureFormat.Brightness = 0.85 shp.PictureFormat.Contrast = 0.15 shp.LockAspectRatio = True shp.height = CentimetersToPoints(14.48) shp.width = CentimetersToPoints(16) shp.WrapFormat.AllowOverlap = True shp.WrapFormat.Side = wdWrapNone shp.WrapFormat.Type = 3 shp.RelativeHorizontalPosition = _ wdRelativeVerticalPositionMargin shp.RelativeVerticalPosition = _ wdRelativeVerticalPositionMargin shp.Left = wdShapeCenter shp.Top = wdShapeCenter End Sub
Cindy Meister, VSTO/Word MVP
Thank you so much for your quick reply.
My document has a Lifecycle attached to it and it has ,status of DRAFT, START,REVIEW,REJECTED, and CLOSE depending on the state of lifecycle. When user Checkout Document from the Documentum, I am getting status of the document in the Custom properties..Property name is status. So i want to take status from custom property and apply the watermark diagonaly. It could be picture / Text ?
Also document pages are not static. When ever document is loaded, it creates dynamic tables and other dynamic text from the custom properties as well..
Please advise, what i can do or what is best in my scanario. I have very limited knowledge of MS Word and Macros.
Thanks for posting in the MSDN Forum.
My document has a Lifecycle attached to it and it has ,status of DRAFT, START,REVIEW,REJECTED, and CLOSE depending on the state of lifecycle.
Would you please clarify it?
Have a good day,
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
I am using documentum to store the documents. I have a type called certificate, which has metadata..So when i create document from documentum , a lifecycle is attached to it along with some other customer information as well to my type. When i checkout document [MS Word Document of my type]..All the metadata is flowing to the custom properties of MS Word Document..and document is being assembeld on the fly..
All this meta data showup in my MS Word document..Similarly status of lifecycle also come to the custome word propertie called status..and i need to create a WaterMark for this..if document is in Draft, it will show the WaterMark Draft when customer looks at it..
Cindy has given the Macro as well, all i need it to pick the watermark from one of my MS Word custome preoperty called status..Dont know how i can do that..
Set shp = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).shapes.AddPicture(FileName:= _ "C:\Users\UserName\Pictures\Avatar.jpg",
If i some how get value of status in place of image, i will be good to go..
Your question falls into the paid support category which requires a more in-depth level of support. Please visit the link below to see the various paid support options that are available to better meet your needs.
Sincerely, Susan Microsoft Community Support
You need to know how documentum has implemented its custom properties. There are several possible ways. Some ways would only work with documents in OOXML (.docx, etc.) format, but for example they could have used:
a. old-style Custom Document Properties (the sort you can insert using DOCPROPERTY fields)
b. Custom XML Parts
c. the same mechanism as SharePoint (which uses Custom XML parts in a well-defined way)
If it's (a), you can use the CUstomDocumentProperties property of the Document - see, e.g. http://word.mvps.org/faqs/macrosvba/MixedDocProps.htm
If it's (c), you may be able to get the values using the ContentTypeProperties property of the document.
If it's (b), you'll need to find out exactly how documentum is representing the properties and get them via the CustomXMLParts collection of the document.
Personally, I would start by having a look at documentum's documentation, looking for old-style Custom Document Properties, looking at the ContentTypeProperties, and/or looking inside a .docx saved from documentum (the usual thing - append .zip to the file name then look inside the customXml and docProps folders).