I have designed a "Russian Lotto" (Bingo-like) card with fancy borders and a 5 by 6 table (to contain random numbers. What I can't figure out is a way to AUTOMATICALLY place each one of those random numbers (in external .csv file) in one of the 30 table fields, CENTERED. It's a pain to drag n drop, then size, etc. I would happily pay for such a tool - can't find such a beast in GDG Macros or MacroMonster. Perhaps I'll have to resort to a long, complex recorded script. Thanks, fellow Forum members.
CorElder said:It's a pain to drag n drop, then size, etc.
I understand why you would want to automate the transfer of the text (numbers of empty strings for blank spaces) from an external source.
It should be straightforward, though, because all of the formatting - the typeface, the font size, the horizontal and vertical alignment - can already be in place on the table.
This is me just clcking and typing, clicking and typing, etc.
So, the macro only needs to get the text content from a file, and then push it into the Paragraph text shapes that make up the table. The access to table contents is sort of ugly, because a table is a custom shape, but it's not bad once one knows how to do it. Setting the value for the text of a table cell will look something like this:
Shape.Custom.cell(lngColumn, lngRow).TextShape.Text.Story = strCellText
If you give the table shape a specific name in your drawing, then the macro could easily know which shape to work on.
The beauty of doing it that way is that you could redesign your card, change the typeface and font size, change the color, etc. - and the exact same macro would still work for populating the text as long as the table has the same number of columns and rows.
Eskimo - I thought I was fairly knowledgeable in CorelDraw (my versions go back about 20 years), but I can see you are more advanced. Thanks so much for the (prompt) help. ..CorElder
I didn't know much about tables in CorelDRAW until I wrote a macro - one that totally revolved around creating and modify a particular table - for a friend. In that case, it was something where he could use a userform to specify the text to be used when creating the table, or modifying an existing one.
Some of the fields in the table were calculated using the numeric values of other fields, so it wasn't just about putting the text into the table.
Hi!! this is exactly what I need to do at the moment and I am STUCK... Basically, I have a "revision history" table that needs to increase by 1 row every time I run the macro, and then populate the cells with some info. I've gotten so far as to selecting the correct object, adding a row... and then nothing! my idea is to count the number of rows on the table and use that as an input for the "Cell" part of a command along these lines: Shape.Custom.Cell(row number, col number).TextShape.Text.Story = "Whatever text here". I cannot for the life of me count the rows. I'm new to this and struggling. Please help?? I will be forever grateful.
I don't comprehensively understand all the details of working with tables, but here are some code snippets that might help with figuring out how to address the last row of the table or a newly-added row of the table.
In all places where I change the text, I am setting the first cell of the row to "foo", and the second cell of the row to "bar".
Sub add_row() Dim s As Shape Set s = ActiveShape s.Custom.AddRow End Sub '-------------------------------------------------------------- Sub change_text_last_row_1() Dim s As Shape Dim lngLastRowIndex As Long Set s = ActiveShape lngLastRowIndex = s.Custom.Rows.Last.Index s.Custom.cell(1, lngLastRowIndex).TextShape.Text.Story = "foo" s.Custom.cell(2, lngLastRowIndex).TextShape.Text.Story = "bar" End Sub '-------------------------------------------------------------- Sub change_text_last_row_2() Dim s As Shape Set s = ActiveShape With s.Custom.Rows.Last .cells.Item(1).TextShape.Text.Story = "foo" .cells.Item(2).TextShape.Text.Story = "bar" End With End Sub '-------------------------------------------------------------- Sub add_row_at_end_and_change_text() Dim s As Shape Set s = ActiveShape With s.Custom.AddRow .cells.Item(1).TextShape.Text.Story = "foo" .cells.Item(2).TextShape.Text.Story = "bar" End With End Sub '-------------------------------------------------------------- Sub add_row_at_row_3_and_change_text() Dim s As Shape Set s = ActiveShape With s.Custom.AddRow(3) .cells.Item(1).TextShape.Text.Story = "foo" .cells.Item(2).TextShape.Text.Story = "bar" End With End Sub
THANK YOU this is exactly what I needed. Much appreciated.