I want to add a new FreeText comment to a PDF file with vba.
Public Sub AddAnnot(Page As Object, Text As String)
Dim Rect As Object, Annot As Object
Set Rect = CreateObject("AcroExch.Rect")
Dim Space As Integer, Height As Integer
Space = 0
Height = 15
With Rect
.bottom = Space
.Left = Space
.Right = Page.GetSize.x - Space
.Top = Space + Height
End With
Set Annot = Page.AddNewAnnot(0, "FreeText", Rect)
With Annot
.SetTitle Text
.SetContents (Text)
.SetColor RGB(255, 255, 0)
.SetRect Rect
End With
End Sub
So this code worked with older versions of Acrobat, but now in Acrobat DC, it always fails at the line .SetContents (Text)
with the simple error, that the method has failed. It doesnt matter, which pdf-file it is, it always fails.
What am i doing wrong? Thanks in advance
For everyone who was desperately searching for a solution to this, but didn't find one: Before the whole procedure of adding Annots, open the document as an AVDoc, too. You don't have to use it, just opened and it works, even when you instantly hide it.