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