View Single Post
  #5   Report Post  
Posted to microsoft.public.word.tables
StevenM[_2_] StevenM[_2_] is offline
external usenet poster
 
Posts: 169
Default macros for tables (2007)

To: Aedcone,

Well, you message appeared to ask for a macro, so I assumed that you had
some familiarity with them.

To Install a Macro:
Go to VBA editor via Tools Macro Visual Basic Editor (or Alt-F11).
Open the Project Explorer (if not open) , the shortcut key is Ctrl-R.
It will have the name €śProject.€ť
Click on the template where you would like to store your macro.
For example click on €śNormal.€ť
Insert a new Module with: Insert Module.
It should have the name Module1.
(You can re-name your new module now or later by clicking on F4, this should
bring up the Properties Window. In the field following €ś(name)€ť you can
change the modules name. Close the Properties window, now the new Module
should have a new name.)
The code window should now be open.
The code window has General & Declarations at the top.
If it is not open, double click on the Module.
Cut and past your macro into the code window.
You can store more than one macro in a module.
To run your macro, go back to your document and click on Alt-F8.
Alt-F8 will bring up the macro menu from which you can pick your macro and
run it.

Steven Craig Miller

"aedcone" wrote:

Hi Steve,

Column 1 has text in it. (200 rows)
I added a second column (no text) (200 rows) which I need to split in two
"cells" or "rows"... the second colum w/the two rows is associated with the
first column

Sorry, but I don't understand what you wrote/ or how your wrote it. I am
new 2007 and macros in this version are way beyond what I did to create
macros in Word 2000.

Sub TableSplitRows()
Dim newDoc As Document
Dim oRange As Range
Dim oTable As Table

Set newDoc = Documents.Add
Set oRange = newDoc.Range
Set oTable = newDoc.Tables.Add(oRange, NumRows:=2, NumColumns:=2)
oTable.Columns(2).Cells(2).Split NumRows:=2
oTable.Columns(2).Cells(1).Split NumRows:=2
End Sub

Anyway, thanks for whatever the above is... I have no idea if this is what i
was looking for... What i actually did is to create a table w/400 rows and
then merged two cells in column to form one cell. It was tedious and time
consuming, but I did get the job done.

"StevenM" wrote:

To: Aedcone,

I'm not following you. I think if you clarified your problem, you might find
someone posting an answer faster.

For example, you stated that you had a table with over 200 rows with text in
it.
Then you added a second column. Is the second column empty or does it have
text in it too?

The you stated that you needed to split the cells in the second column and
create two rows. Yes?

Now, if I'm understanding you here, the first column has over 200 rows, so
does that mean you want the second column to have over 400 rows? So that for
each row in column one, there will be two rows in column two?

For example, do you need a table which looks something like:

Sub TableSplitRows()
Dim newDoc As Document
Dim oRange As Range
Dim oTable As Table

Set newDoc = Documents.Add
Set oRange = newDoc.Range
Set oTable = newDoc.Tables.Add(oRange, NumRows:=2, NumColumns:=2)
oTable.Columns(2).Cells(2).Split NumRows:=2
oTable.Columns(2).Cells(1).Split NumRows:=2
End Sub

Steven Craig Miller

"aedcone" wrote:

I have table that consists of over 200 rows with text already in it. I've
added a second column. I now need to split the cells in the second colum
into two rows... This is to create a pedigree chart of sorts... I want to
create a macro to do this, but I can't seem to start the macro for
anything... Normally, I would right click in the cell, select split table,
change the column to 1, the rows to 2. This is macro I need to create, but
it won't let met right click in the cell whilst I have the "developer" tab
up, and when i go to the Insert table and select table, I don't get the menu
to split the table...

Help is needed asap... as it is, it's a big PIA to do this cell by cell...
and I thought a macro would help...

TIA