Excel to CorelDraw - insert text from xls through multiple pages to different positions

Hello people of the Corel!
I am a total newbie when it comes to VBA so please go easy on me. :)
I'm trying to make a macro that takes the cells from an excel file and inserts the text from them through multiple pages. I basically want a print merge but with different positions through the pages.
I picked an already exisitng macro that used some coloumns for positions and a coloumn for the shape it inserts. It also had notes for the inner working of the macro.
Tried to modify it so it reads one more coloumn for the number of the page it should jump on and isnert text instead of a shape.

Here is the code:

Sub GetXcelpaste0()

Dim XL As Object                                                            'The Excel apllication
Dim n As Double
Dim ro1st As Double                                                        '1st Row in Sheet to be processed
Dim roFin As Double                                                        'Final Row in the sheet to be processed
Dim p As Double, x As Double, y As Double                   'The objects intended location with page number
                                                                                         '(Excel uses Radians by default)
Dim a As String                                                                'The price I want to insert
ActiveDocument.Unit = cdrMillimeter                               'Set Corel to work in Millimeters
ActiveDocument.ReferencePoint = cdrBottomLeft           'Set Cdrw to work on bottom left corner

Set XL = GetObject(, "Excel.Application")                        'Sets corel to work with currently active excel sheet
                                                                                          'Excel uses (Row, Coloum) but VB uses (Coloum, Row).
'eg, Excel Cell A2 = VB (2,1)

ro1st = XL.Cells(1, 7).Value                                               'cell A7 contains the value for the 1st Row of data
roFin = XL.Cells(1, 8).Value                                               'cell A8 contains the value of the Final row

Optimization = True                                                            'turn off updating the screen etc.

For n = ro1st To roFin                                                         'read in values

p = XL.Cells(n, 4).Value
x = XL.Cells(n, 5).Value
y = XL.Cells(n, 6).Value
a = XL.Cells(n, 3).Value

ActiveDocument.Pages(p).Activate                                     'jump to the page
Set a = ActiveLayer.Paste                                                   'paste the price
a.SetPosition x, y                                                                 'set its position

Next n

Optimization = False                                                           'turn on updating the screen etc.

End Sub

When I tried to run it, it shows "Compile error: Object required". Tbh I'm not sure how it even reads the test excel file I made. Shouldn't be a code in it that points directly at the xls file?
Could you guys help me repair this?

Parents
No Data
Reply Children
No Data