gpt4 book ai didi

com - LuaCOM Word 文档标题

转载 作者:行者123 更新时间:2023-12-03 00:22:31 25 4
gpt4 key购买 nike

我正在尝试进行一些 LuaCOM 编程来创建 Word 文档。我已经弄清楚了大部分内容,但似乎无法理解页眉/页脚的工作原理。

word = luacom.CreateObject("Word.Application")


book = word.documents:Add()
word.Visible = true



paras = book.Paragraphs:Add()
range = paras.Range

range.Text = ([[Nam fabulas mnesarchum comprehensam ne, cu ullum euismod consulatu usu. Eam alii lobortis voluptatum id, denique eligendi pertinax quo ne. Vis congue eirmod ut. Duo probo soleat ex. Elit pertinax abhorreant eu his, ipsum dicam dissentiunt pri id. Kasd erant dolorum id sed, ei vim partem deseruisse, ne mea dico tantas alienum.
Has cu facilisis mediocritatem. Fabellas lucilius vim ex.
]])

book.InlineShapes:AddPicture("C:\\13.png", 0, 1);
range.Style = ("Normal")
range:InsertParagraphAfter()

word.DisplayAlerts = false;

doc = nil
word = nil

在这里,我只是创建一个带有段落的标准文档,并在顶部附近添加图像。我希望将图像放在标题中,并在标题中居中放置一些文本。

预先感谢您的帮助!

最佳答案

这对我有用:

require("luacom")
local word = luacom.CreateObject("Word.Application")
local book = word.documents:Add()
word.Visible = true
local section = book.Sections(1)
local headers = section.Headers
local header = headers:Item(1)
header.Range.Text = "HEADER"
header.Range.InlineShapes:AddPicture("C:\\13.png", 0, 1);
doc = nil
word = nil

关于com - LuaCOM Word 文档标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16823896/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com