Connecting CorelDraw to Excel

nicksoph

Board Regular
Joined
Jun 13, 2009
Messages
57
Hi

I am plotting a large number of circles (70,000) in Coreldraw and would like to be able to do this directly from CorelDraw (I have been doing it using a CSV file, which works fine but I cant help but want to see it done better).

The file is called PLOT and has a sheet called CALCS which contains 6 rows of data which give;

x and y cordinates, radius of cicrle to be plotted and the circles colour in RGB

The spreadsheet also contains 2 cells which show the 1st and last row numbers to be plotted. (cells A3 and A4)

The Macro code below is intended to run in CorelDraw with Excel open and Im reasonably confident that the bits that relate to Coreldraw work, but I am unsure of the Excel bits. In particular what should the Get Object be referencing? and should there be commas in between the letters and digits of the cell references. (see italics below).

I would appreciate it if someone would have a look and comment on what I need to do to get the info in.

best wishes
Nic



Sub GetXcel()
Dim XL As Object 'The Excel apllication
Dim Ro1st As Double 'Will contain the value of - 1st Row in Sheet to be processed
Dim RoFin As Double 'Will contain the value of - Final Row in the sheet to be processed
Dim sCircle As Shape
Dim x As Double, y As Double, Rd As Double ' x,y co ordinates and radius of circle to be plotted
Dim R As Double, G As Double, B As Double ' the colour the circle is to be in RGB
ActiveDocument.Unit = cdrMillimeter 'Set Corel to work in Millimeters

Set XL = GetObject(sheet1, "Excel.Application")

Ro1st = XL.Cells(A3).Value ' cell A3 contains the value for the 1st Row
RoFin = XL.Cells(A4).Value ' cell A4 contains the value of the Final row

Optimization = True ' turn off updating the screen etc.

For n = Ro1st To RoFin

x = XL.Cells(e, n).Value ' start to set values for variables
y = XL.Cells(f, n).Value
Rd = XL.Cells(G, n).Value

R = XL.Cells(h, n).Value
G = XL.Cells(i, n).Value
B = XL.Cells(j, n).Value

Set sCircle = ActiveLayer.CreateEllipse2(x, y, Rd) ' place circle at x,y with radius Rd
sCircle.Fill.UniformColor.RGBAssign R, G, B

Next n

Optimization = False ' turn on updating the screen etc.

End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Still working on this - Ive stripped out the coreldraw stuff hoping that the less I write the clearer it will be.


Sub GetXcel()
Dim XL As Object 'The Excel apllication
Dim Ro1st As Double 'Will contain the value of - 1st Row in Sheet to be processed
Dim RoFin As Double 'Will contain the value of - Final Row in the sheet to be processed


Set XL = GetObject("", "Excel.Application")
Ro1st = XL.Worksheets("Sheet1").Cells(A3).Value ' cell A3 contains the value for the 1st Row
RoFin = XL.Worksheets("Sheet1").Cells(A4).Value ' cell A4 contains the value of the Final row

For n = Ro1st To RoFin
x = XL.Cells(5, n).Value ' start to set values for variables
y = XL.Cells(6, n).Value
Rd = XL.Cells(7, n).Value
Set sCircle = ActiveLayer.CreateEllipse2(x, y, Rd) ' place circle at x,y with radius Rd

Next n

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,864
Messages
6,121,981
Members
449,058
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top