Views

Histats

Vitrine

VBA Excel - Exemplos de Copiar e Colar - 05

Este código colará a partir de um intervalo do MS Excel num documento do MS Word, deixando-o interligado ao MS Excel.

Sub LinkWorkBookToMsWord()
    Dim xlTable As Object
    Dim r As Range
    Set r = Worksheets("Sheet1").Range("A1", Range("B65536").End(xlUp))
    Set xlTable = CreateObject("Word.Application")

    xlTable.Visible = True
    r.Copy
    xlTable.documents.Add
    xlTable.Selection.PasteSpecial Link:=True, DataType:=wdPasteOLEObject, Placement:= _
                                   wdInLine, DisplayAsIcon:=False
    xlTable.activedocument.SaveAs ThisWorkbook.Path & "/" & "LinkedToWord.doc"
    xlTable.documents.Close
    xlTable.Quit
    Application.CutCopyMode = False
End Sub

Tags: Excel, VBA, copy, paste, 


Inline image 1

LinkWithinBrazilVBAExcelSpecialist

Related Posts Plugin for WordPress, Blogger...