如何在MS Word Document中添加动态水印形成客户属性? [英] How to add a dynamic watermark in MS Word Document form the custome property?
问题描述
大家好,
我需要在文档中添加动态水印。我在MS Word文档的自定义属性中获得水印图像URL。我确定这是开发问题,请指教?
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)在文档中有一个隐藏字段,在打开时更新
1) have a hidden field in document which gets updated on open
2)有些mactro读取这个隐藏字段并在文档中添加水印,例如..在我们的例子中它将是http链接到水印图像或它也可能是文本..
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?
谢谢,
Khawar
推荐答案
你好Khawar
Hi Khawar
我使用Word的宏录制器记录在文档中插入水印。然后,我编辑了代码,使其更加"精简"。结果如下。
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 = wdShapeCenterEnd Sub
这篇关于如何在MS Word Document中添加动态水印形成客户属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!