我正在寻找Excel + VBA和PDF之间接口的解决方案。我正在使用VBA在PDF文件中插入注释。
截至目前,我可以创建Freetext Box并添加文本。但我没有使用所需的字体类型,字体颜色和字体大小。
这是完整的代码。
Function text_annotation(FileName, path, Proj_No, Dept_no, New_tag, sizex, sizey)
Dim pdDoc As Acrobat.CAcroPDDoc
Dim page As Acrobat.CAcroPDPage
Dim jso As Object
Dim point(2) As Integer
Dim popupRect(3) As Integer
Dim rect(3) As Integer
Dim pageRect As Object
Dim annot As Object
Dim props As Object
Dim text As Object
Set pdDoc = Nothing
Set app = CreateObject("AcroExch.App")
Set pdDoc = CreateObject("AcroExch.PDDoc")
fullpath = path & FileName
pdDoc.Open (fullpath)
Set jso = pdDoc.GetJSObject
If Not jso Is Nothing Then
Set page = pdDoc.AcquirePage(0)
Set pageRect = page.GetSize
Set annot = jso.AddAnnot
Set props = annot.getprops
props.page = 0
props.Name = "Entry_Stamp"
props.Type = "FreeText"
props.rect = popupRect
props.Author = "user"
props.Width = 1#
props.strokeColor = jso.color.blue
props.contents = "text mesg"
annot.setProps props
以下这些行未正确显示。
Set props = annot.getprops
With props
'props.text = jso.color.blue
'props.Fontcolor = jso.color.black
'props.textFont = Font.Helv
'props.textSize = 24
End With
annot.setProps props
End Function
我希望使用VB脚本,以便我可以使用我的Excel模板以及注释。请在上面的代码中建议我更正。