Format for Excel VBA addWatermarkFromText

题意:“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:

“我有一段 VBA 代码,它整合了多个 PDF 文件,然后为每一页添加水印(页码和页脚),这段代码是我找到的,运行得很好:”

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.

“我查阅了 JavaScript API 参考,了解如何格式化水印,以便利用各种参数。在这种情况下,我想使用 'nHorizAlign'。不过,我在 VBA 代码中格式化这个参数时遇到了一些困难。我只需要保留现有的参数,并添加 'nHorizAlign',这样文本字符串就会位于页面的左侧。”

The Javascript version would be as follows:

“JavaScript 版本如下:”

    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.

“当我使用 'nHorizAlign:=Left' 或 'nHorizAlign:=(某个数字)' 时,它不起作用。”

Assistance is much appreciated.

“非常感谢您的帮助。”

问题解决:

The following code aligns the cText horizontally on the left:

“以下代码将 cText 水平对齐到左侧:”

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

营赢盈英

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值