Need help with Importing TXT file and inserting into Variables Print Merge

Hi,

I'm really hoping someone can help me.

I am engraving pet tags and each tag has different names on them. I have tag jig files made up that have each pet tag shape and inside each tag has variable lines eg : <tag16line1> please see image.
I also have TXT files that has the details (pets names) that need to be imported into the variable lines of each tag in the jig file (image attached).  I have no idea how to import them into this file. Hoping someone can please help me?

Parents
No Data
Reply
  • Hello everyone,
    I see that the discussion is quite advanced. I am offering my code which I use to solve similar problems. Things like Mail Merge in Corel have quite a few issues, especially in older versions, and I've turned it off entirely. The data file is in Excel. Adaptation of the code to receive data from a *.txt file is possible. It can be given from the text file to open in Excel. For the code to work, the required Excel data file pets.xlsx is open.

    In column A, dogname1…dogname20 are recorded. Column B contains OwnerName1…OwnerName20. In column C are recorded OwnerTel1…OwnerTel20.

    My code is not perfect and can certainly be written better. It has some solutions that can increase the user's performance in solving such tasks. Corel file contains Fields_Layer, Cut_Layer, Layer_New.

    Currently the code works with 20 entries /20 pet names/ but this can easily be changed.

    Principle of operation: /I will not comment on the possible improvements, there are many/

    1. The data for each pet is saved in pets.xlsx, which must be open.
    2. Corel code is launched from Private Sub CommandButton110_Click(). The function of the code is that it reads the text in FIELDS_LAYER. For all DogName texts in FIELDS_LAYER, it writes in the same position of DogName, but in another layer – LAYER_NEW the names of the pets it takes from the open pets.xlsx.

    Now the code only handles DogName. OwnerName, OwnerTel processing can be done in a similar way.

    Greetings!

    Here is the code:

    Private Sub CommandButton110_Click()

    Dim myobjectXL As Excel.Application

    Set myobjectXL = GetObject(, "Excel.Application") 'refers to open instance of Excel

    Set myrange = myobjectXL.Worksheets(1).Range("A:A") 'List of pets names

    CountOfPets = myobjectXL.WorksheetFunction.CountA(myrange)

    Dim DSHAPE As Shape

    For Each DSHAPE In ActivePage.Layers("FIELDS_LAYER").Shapes

    flag = flag + 1

    If DSHAPE.Type = 6 Then

    If DSHAPE.Text.Range(0, 1000) = "DogName" Then

    VCENTERX = DSHAPE.CenterX

    VCENTERY = DSHAPE.CenterY

    Dim s1 As Shape

    Set s1 = ActivePage.Layers("LAYER_NEW").CreateArtisticText(1.771646, 11.417315, myobjectXL.Worksheets(1).Cells(flag, "A").Value)

    s1.Fill.UniformColor.CMYKAssign 0, 0, 0, 100

    s1.Outline.SetNoOutline

    s1.Text.Range(0, 100).Size = 10 ‘Font Size

    With s1

    .CenterX = VCENTERX

    .CenterY = VCENTERY

    End With

    End If

    End If

    Next

    Me.Hide

    ActivePage.Layers("FIELDS_LAYER").Visible = False

    ActivePage.Layers("LAYER_NEW").Visible = True

    End Sub

       

Children