카테고리 없음

[vba] Excel의 범위에서 Word 문서로 텍스트 복사

행복을전해요 2021. 1. 12. 11:09

다음은 도움이 될 수있는 몇 가지 도움말입니다.

Microsoft Excel에서 VBA를 사용하여 Excel에서 Word 제어

Excel VBA로 Word 문서 만들기

Excel 데이터 범위에서 서식이 지정된 Word 표 만들기

-------------------

다음은 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
                                                                                

자세한 내용은 여기

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



출처
https://stackoverflow.com/questions/2006150