Copy Text from Range in Excel into Word Document

后端 未结 2 559
耶瑟儿~
耶瑟儿~ 2020-12-11 12:21

how do you:

1) copy text from a range in an Excel Document.
2) Open a Word Document.
3) inserts the text into a specific part of the word document.

相关标签:
2条回答
  • 2020-12-11 12:59

    Here are some articles that may help:

    Control Word from Excel using VBA in Microsoft Excel

    Creating a Word Document with Excel VBA

    Create formatted Word table from Excel data range

    0 讨论(0)
  • 2020-12-11 13:16

    Here's some code I wrote for replacing bookmark text in Word

    Sub FillBookmark(ByRef wdDoc As Object, _
        ByVal vValue As Variant, _
        ByVal sBmName As String, _
        Optional sFormat As String)
    
        Dim wdRng As Object
    
        'store the bookmarks range
        Set wdRng = wdDoc.Bookmarks(sBmName).Range
    
        'if the optional format wasn’t supplied
        If Len(sFormat) = 0 Then
            'replace the bookmark text
            wdRng.Text = vValue
        Else
            'replace the bookmark text with formatted text
            wdRng.Text = Format(vValue, sFormat)
        End If
    
        're-add the bookmark because the above destroyed it
        wdRng.Bookmarks.Add sBmName, wdRng
    
    End Sub
    

    More details here

    http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/

    0 讨论(0)
提交回复
热议问题