excel - 将Excel中的文本粘贴到Word标题中?

标签 excel header ms-word vba

我正在尝试添加 Belkin到我的word文档的标题。

情况:Excel: A1 = Belkin | Word: header needs to get Belkin

最佳答案

这是一个快速而肮脏的 Excel VBA 来帮助您 - 创建一个新的 word 应用程序/word doc 并将 A1 的内容粘贴到标题中......

Sub CreateWordDocWithHeader()
Dim WApp As Word.Application
Dim WDoc As Word.Document
Dim WRng As Word.Range

    Set WApp = New Word.Application
    WApp.Visible = True
    Set WDoc = WApp.Documents.Add
    Set WRng = WDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range
    WRng = ActiveSheet.[A1]

    Set WRng = Nothing
    Set WDoc = Nothing
    Set WApp = Nothing
End Sub

希望这会有所帮助....祝你好运

关于excel - 将Excel中的文本粘贴到Word标题中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5550959/

相关文章:

excel - 在查找功能中包括第一行

python - 使用 Python Pandas 在一个 Excel 文件中创建多个电子表格

excel - 未找到 getElementById 时捕获错误

excel - 以下代码行之间的区别

c# - 如何通过Word文档修改 "walk"的内容?

ios - heightForHeaderInSection 只调用一次

version-control - 在二进制文件中添加 RCS header

javascript - header 运费国家标志

javascript - DOCX Javascript 库追加表行

java - 如何通过自定义 Web 应用程序连接到 Alfresco 文档