Hi,
I have to make a macro to create a Table with a specifyed header
|name|position|
at the end of a the document and i have to fill it with the
informations content in other tables in certain cells.
existing table example:
| cell1 | cell2 | name |position |cell5 |
|content1|content2| content3|content4 |cont5|
new table should look like
|name |position |
|content3|contetn4 |
could anyone gimme some clues?
Thank You,
catalin
Shauna Kelly - 26 Feb 2007 21:10 GMT
Hi
As I understand it, you want to copy the first table in your document to the
end of the document, and then delete the first two columns and the last
column. If that's the case, then the following will do that:
Sub CopyTableAndDeleteColumns()
Dim oOldTable As Word.Table
Dim oNewTable As Word.Table
Set oOldTable = ActiveDocument.Tables(1)
oOldTable.Select
Selection.Copy
ActiveDocument.Range.InsertAfter vbCrLf
Selection.EndKey Unit:=wdStory
Selection.PasteAndFormat wdPasteDefault
Set oNewTable = ActiveDocument.Tables _
.Item(ActiveDocument.Tables.Count)
With oNewTable.Columns
.Last.Delete
.First.Delete
.First.Delete
End With
End Sub
You'll need to add some error checking to cope if the table has any merged
cells, because you will not then be able to delete the columns.
Hope this helps.
Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
> Hi,
> I have to make a macro to create a Table with a specifyed header
[quoted text clipped - 10 lines]
> Thank You,
> catalin
cmarangoci@gmail.com - 27 Feb 2007 07:34 GMT
Hi,
Thank you very much for help, the fault for not beeing exactly what i
wanted is mine only.. i didn't wrote exacly what i wanted.. i
appologise.... so what i truly need is a macro to identify all
"initial" tables that have a header
like | cell1 | cell2 | name |position |cell5 | and to take the
3rd and 4th cells content from the second row of this table( the cells
under |name| and |position|) and put them in the "results" table i
create at the end of the document...
so mainly
- those "initial" tables are spred allower the document.. not in
predefined positions...and i have to identify them by "name" and
"position" = the content of cell 3 and cell 4 from first row of the
tables...
- the "result" table i create at the end of the document with header |
name |position | and i add a row for every "initial" table i
find... and in this row i place the content of 3rd and 4th cells from
second rows from "initial" tables....
thank you very much for your help so far,,,
Catalin
Shauna Kelly a scris:
> Hi
>
[quoted text clipped - 47 lines]
> > Thank You,
> > catalin