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 apllicationDim n As DoubleDim ro1st As Double '1st Row in Sheet to be processedDim roFin As Double 'Final Row in the sheet to be processedDim 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 insertActiveDocument.Unit = cdrMillimeter 'Set Corel to work in MillimetersActiveDocument.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 dataroFin = 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).Valuex = XL.Cells(n, 5).Valuey = XL.Cells(n, 6).Valuea = XL.Cells(n, 3).Value
ActiveDocument.Pages(p).Activate 'jump to the pageSet a = ActiveLayer.Paste 'paste the pricea.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?
Send me PM via this page.