I am trying to figure out how to use VBA to programmatically create a highlight annotation in a .pdf document. I am using the Adobe Acrobat 10.0 Type Library reference and I have set the objects for the document and page that I want. Below is an example of a code that IS working, but I cannot seem to figure out the language for a "highlight" annotation that would need a bounding rectangle rather than a "Text" annotation which only needs 2 points like below. The result in the .pdf document from the code below is that a sticky note is created in the .pdf based on the coordinates "Lpos" and "Tpos".Sub CreateAnnotation(PDDoc As Acrobat.CAcroPDDoc, page As Acrobat.CAcroPDPage, Lpos, Tpos, CommentString)
'Creates an annotation "Sticky Note" in a .pdf document
Dim HiList As Acrobat.AcroHiliteList
Dim PDTextSelect As Acrobat.CAcroPDTextSelect
Dim PDRec As AcroRect
Dim jso As Object
Dim path As String
Dim point(1) As Integer
Dim t As Integer
Dim popupRect(3) As Integer
Dim pageRect As Object
Dim annot As Object
Dim props As Object
Set jso = PDDoc.GetJSObject
Set pageRect = page.GetSize
point(0) = Lpos
point(1) = Tpos
popupRect(0) = 0
popupRect(1) = pageRect.y - 100
popupRect(2) = 100
popupRect(3) = pageRect.y - 200
' Create a new text annot
Set annot = jso.AddAnnot
Set props = annot.getProps
props.Type = "Text"
annot.setProps props
' Fill in a few fields
Set props = annot.getProps
props.page = page.GetNumber
props.point = point
props.popupRect = popupRect
props.Author = "mthompson"
props.noteIcon = "Comment"
props.strokeColor = jso.Color.blue
props.Contents = CommentString
annot.setProps props
End Sub
'Creates an annotation "Sticky Note" in a .pdf document
Dim HiList As Acrobat.AcroHiliteList
Dim PDTextSelect As Acrobat.CAcroPDTextSelect
Dim PDRec As AcroRect
Dim jso As Object
Dim path As String
Dim point(1) As Integer
Dim t As Integer
Dim popupRect(3) As Integer
Dim pageRect As Object
Dim annot As Object
Dim props As Object
Set jso = PDDoc.GetJSObject
Set pageRect = page.GetSize
point(0) = Lpos
point(1) = Tpos
popupRect(0) = 0
popupRect(1) = pageRect.y - 100
popupRect(2) = 100
popupRect(3) = pageRect.y - 200
' Create a new text annot
Set annot = jso.AddAnnot
Set props = annot.getProps
props.Type = "Text"
annot.setProps props
' Fill in a few fields
Set props = annot.getProps
props.page = page.GetNumber
props.point = point
props.popupRect = popupRect
props.Author = "mthompson"
props.noteIcon = "Comment"
props.strokeColor = jso.Color.blue
props.Contents = CommentString
annot.setProps props
End Sub