从Word中的Excel中粘贴文本?

我正在试图将Belkin添加到我的Word文档的标题中。

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

这里有一个快速和肮脏的Excel VBA让你去 – 创build一个新的单词应用程序/文字文件,并将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 

希望这有助于….祝你好运miked