none
How to use AD RMS account name as the watermark of word document? RRS feed

  • Question

  • My document is protected by AD RMS, I want to use current account name who open the doc as the watermark text of this doc.

    Please see the picture bellow, I want use the red part as the watermark, which means the doc has "dynamic" watermark

    Wednesday, November 29, 2017 10:03 AM

All replies

  • Hello,

    Office Object Model does not provide any property or method to retrieve the signed account in Office application, we could only get the current user of the machine. So it is impossible to achieve your requirement. 

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 30, 2017 4:49 AM
    Moderator
  • Can I retrieve the account by vba or plug in?
    Thursday, November 30, 2017 8:33 AM
  • Can I retrieve the account by vba or plug in?

    No. Office Object Model does not provide any property or method to retrieve the signed account in Office application.

    We could only use Application.UserName Property (Excel) to return the name of the current user. It is the same as current user of machine by default.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 30, 2017 8:37 AM
    Moderator
  • Hi 汪汪已存在,

    you had mentioned that," I want to use current account name who open the doc as the watermark text of this doc."

    you cannot access account name but you can fetch the "Last Author" Name.

    with the help of that you can know that who modify the document last time.

    you can see the same details by clicking the "Info" Button in File Tab.

    also you can check it by right click the file and see properties.

    you can also check the total number of time this document been modified.

    below is a VBA code to fetch "Last Author" name.

    Sub demo()
     Dim name As String
     name = ActiveDocument.BuiltInDocumentProperties("Last Author")
     MsgBox "Last Time document was modified by " & name
    End Sub
    

    Reference:

    Document.BuiltInDocumentProperties Property (Word)

    to add the WaterMark you can refer example below.

    Sub InsertWaterMark()
        Dim strWMName As String
         
        On Error GoTo ErrHandler
        
        ActiveDocument.Sections(1).Range.Select
        strWMName = ActiveDocument.Sections(1).Index
        ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
         'Change the text for your watermark here
        Selection.HeaderFooter.Shapes.AddTextEffect(msoTextEffect1, _
        "WaterMark text", "Arial", 1, False, False, 0, 0).Select
        With Selection.ShapeRange
             
            .Name = strWMName
            .TextEffect.NormalizedHeight = False
            .Line.Visible = False
             
            With .Fill
                 
                .Visible = True
                .Solid
                .ForeColor.RGB = Gray
                .Transparency = 0.5
            End With
             
            .Rotation = 315
            .LockAspectRatio = True
            .Height = InchesToPoints(2.42)
            .Width = InchesToPoints(6.04)
             
            With .WrapFormat
                .AllowOverlap = True
                .Side = wdWrapNone
                .Type = 3
                 
            End With
             
            .RelativeHorizontalPosition = wdRelativeVerticalPositionMargin
            .RelativeVerticalPosition = wdRelativeVerticalPositionMargin
             
            .Left = wdShapeCenter
            .Top = wdShapeCenter
        End With
         
        ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
         
        Exit Sub
         
    ErrHandler:
        MsgBox "An error occured trying to insert the watermark." & Chr(13) & _
        "Error Number: " & Err.Number & Chr(13) & _
        "Decription: " & Err.Description, vbOKOnly + vbCritical, "Error"
         
         
    End Sub
    
    
    

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 1, 2017 6:21 AM
    Moderator