I use my excel sheet to use a vba-macro. The macro create a new word-document and by use a mailing-label id. Now i want to fill the label with some data from my exel sheet. I tried it with an array. My idea would looks like: 1. create Word object 2. create mailing.label 3. load my excel vba-array by loop into the mailing.label

my code to create the document

Sub test()

Dim oDoc As Object
    On Error Resume Next
    Set appwd = GetObject(, "Word.Application")
    If Err Then
        Set appwd = CreateObject("Word.Application")
    End If
    On Error GoTo 0
    With appwd
        If .Documents.Count = 0 Then
        End If
        Set oDoc = .MailingLabel.CreateNewDocumentByID(LabelID:="1359804674")
        .Visible = True
        'Do stuff with oDoc here
    End With

End Sub

0 Answers