开发者

pasting text from Excel in Word header?

开发者 https://www.devze.com 2023-02-22 08:05 出处:网络
I\'m trying to add Belkin开发者_StackOverflow中文版 to the header of my word document. Situation:

I'm trying to add Belkin开发者_StackOverflow中文版 to the header of my word document.

Situation: Excel: A1 = Belkin | Word: header needs to get Belkin


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 ....

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号