vba 将 Excel 中的文本粘贴到 Word 标题中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5550959/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pasting text from Excel in Word header?
提问by CustomX
I'm trying to add Belkin
to the header of my word document.
我正在尝试添加Belkin
到我的 Word 文档的标题中。
Situation:
Excel: A1 = Belkin | Word: header needs to get Belkin
情况:
Excel: A1 = Belkin | Word: header needs to get Belkin
回答by MikeD
here's a quick & dirty Excel VBA to get you going - creating a new word application/word doc and pasting the content of A1 into the header ....
这是一个快速而肮脏的 Excel VBA,可以帮助您前进 - 创建一个新的单词应用程序/单词文档并将 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
Hope this helps .... Good luck miked
希望这会有所帮助......祝你好运