OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-05-2010, 16:06
nic nic is offline
Member
 
Join Date: May 2009
Posts: 90
Default Working with Excel

This isnt a question, just an example of Coreldraw working with Excel
I have found it useful to create patterns in Coreldraw by creating the numbers in Excel.

All of it is from this forum.

The macro pastes the clipboard numerous times and requires an excel spreadsheet where each row shows;
(x,y)location, (rgb) colour, and rotation.

Code:
Sub GetXcelpaste2()
'This macro reads an Excel spreadsheet to place, 
'rotate and colour the contents of the clipboard.
'Each line of the spreadsheet represents one object
'The spread sheet contains 6 columns (A to F),
'x,y,r,g,b and Rotation
'and two cells (here Cells A7 and A8) containing 
'the numbers of the first and last row of the data to be processed


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 sclip As Shape
Dim x As Double, y As Double    'The objects intended location
Dim Ro As Double                 'The objects intended rotation in degrees 
                                     '(Excel uses Radians by default)
Dim r As Double, g As Double, b As Double        'The objects colour in RGB

ActiveDocument.Unit = cdrMillimeter             'Set Corel to work in Millimeters
ActiveDocument.ReferencePoint = cdrCenter  'Set Cdrw to work on centres

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(7, 1).Value 
                          ' cell A7 contains the value for the 1st Row of data
roFin = XL.Cells(8, 1).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
x = XL.Cells(n, 1).Value
y = XL.Cells(n, 2).Value
r = XL.Cells(n, 3).Value
g = XL.Cells(n, 4).Value
b = XL.Cells(n, 5).Value
Ro = XL.Cells(n, 6).Value

Set sclip = ActiveLayer.Paste              'paste the clipboard
sclip.SetPosition x, y                          'set its position
sclip.Rotate Ro                                  'rotate it
sclip.Fill.UniformColor.RGBAssign r, g, b   'colour it

Next n

Optimization = False ' turn on updating the screen etc.

End Sub
Reply With Quote
  #2  
Old 02-05-2010, 18:37
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Cool Nic.
It would be nice to see some of the files your creating with this, or some excel files so we can have some fun with your code.
You may have to add activewindow.refresh at the bottom after turning your optimization off.

-John
Reply With Quote
  #3  
Old 03-05-2010, 02:59
nic nic is offline
Member
 
Join Date: May 2009
Posts: 90
Default

Hi John

Firstly - a correction to the macro as posted
the two lines
ro1st = XL.Cells(7,1) and (8,1) should read

ro1st = XL.Cells(1, 7)
roFin = XL.Cells(1, 8)

Ive got to say the bits done with the macro are a bit naff and my earlier statement about using it to create patterns is virtually a lie, but ive attached two cdrs which were done mostly by either running several macros or manually. I was after reshading these images to give a 3d effect to the whole but my maths really isnt up to it and the macro posting was my way of letting it go.

Also attached is a example excel workbook with 1 sheet holding the calcs and the 2nd being used to plot. It simply rotates and shades what ever is on the clipboard depending on how far it is from the origin; it might be useful as a starting point.

Thanks for your help
nic
Attached Files
File Type: zip exp.zip (630.5 KB, 429 views)
Reply With Quote
  #4  
Old 03-05-2010, 10:00
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Smile

Quote:
Originally Posted by nic View Post
Hi John
I was after reshading these images to give a 3d effect to the whole but my maths really isnt up to it and the macro posting was my way of letting it go.
nic
You might also use as a way to store a selected shape into your excel file also.
-John
Reply With Quote
Reply

Tags
excel paste


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedding 2007 EXCEL Flow_FX Feature requests/wishlist 0 27-03-2008 14:35
CD X3 Macro Writing to Excel Spreadsheet JudyHNM Code Critique 5 16-08-2007 10:57
Import / Paste Excel into CorelDraw 12 JIMXAV General 3 11-05-2007 08:11
Is Corel to Excel data exchange possible? alex69 CorelDRAW/Corel DESIGNER VBA 8 24-06-2004 05:52
Excel worksheet Seelenquell CorelDRAW/Corel DESIGNER VBA 2 02-02-2004 10:28


All times are GMT -5. The time now is 04:23.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com