简体   繁体   中英

Format for Excel VBA addWatermarkFromText

I have a VBA code which consolidates various PDF files and then adds a watermark (page number and footer) to each page, which is some code I found and is working fine:

Set jso = PartDocs(0).GetJSObject

    For q = 2 To n

        jso.addWatermarkFromText _
            cText:=Str(q) & "  ", _
            nFontSize:=10, _
            nStart:=q - 1, _
            nEnd:=q - 1
    Next q

        Set jso = Nothing

I have looked up the JavaScript API reference which shows how to format the watermark, in order to get use out of the various parameters. In this case, I want to use "nHorizAlign". However, I am having a bit of trouble figuring out how to format this in VBA code. All I need to do is keep the parameters I already have, but add "nHorizAlign" so that the text string will be on the left side of the page.

The Javascript version would be as follows:

    this.addWatermarkFromText({
      cText: "Example",
      nTextAlign: app.constants.align.left,
      nHorizAlign: app.constants.align.left,
      nVertAlign: app.constants.align.top,
      nHorizValue: -72, nVertValue: -72
    });

When I used "nHorizAlign:=Left" or "nHorizAlign:=(some number)" it does not work.

Assistance is much appreciated.

The following code aligns the cText horizontally on the left:

Set jso = PartDocs(0).GetJSObject

    For q = 2 To n

        jso.addWatermarkFromText _
            cText:=Str(q) & "  ", _
            nFontSize:=10, _
            nHorizAlign:=0, _
            nVertAlign:=4, _
            nStart:=q - 1, _
            nEnd:=q - 1
    Next q

        Set jso = Nothing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM