ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   automatically number a table in word document (https://www.excelbanter.com/excel-programming/442855-automatically-number-table-word-document.html)

VinceW

automatically number a table in word document
 
The code below opens the correct document but now I would like to number the
cells in the table. The document has 2 tables both with 2 columns in them.
I would like to automatically number the cells in table column 1 of table 2.
Any help is very much appreciated.

Thank you

Dim appWD As Word.Application
Set appWD = CreateObject("Word.Application")
appWD.Documents.Open ("C:\Microsoft Office
Datafiles\Word\DailyNotes\DailyNotes " & strDate & ".doc")
appWD.Visible = True



Jacob Skaria

automatically number a table in word document
 
Modify the filename to suit...

Dim appWD As Word.Application
Dim docWD As Word.Document

Set appWD = CreateObject("Word.Application")
Set docWD = appWD.Documents.Open("d:\New.doc")

appWD.Visible = True

For intRow = 1 To docWD.Tables(2).Rows.Count
docWD.Tables(2).Cell(intRow, 1).Range.Text = intRow
Next

--
Jacob (MVP - Excel)


"VinceW" wrote:

The code below opens the correct document but now I would like to number the
cells in the table. The document has 2 tables both with 2 columns in them.
I would like to automatically number the cells in table column 1 of table 2.
Any help is very much appreciated.

Thank you

Dim appWD As Word.Application
Set appWD = CreateObject("Word.Application")
appWD.Documents.Open ("C:\Microsoft Office
Datafiles\Word\DailyNotes\DailyNotes " & strDate & ".doc")
appWD.Visible = True



VinceW

automatically number a table in word document
 
Thank you very much works perfectly.

How about 1 more question for you.

I would like to be able to copy the information from table 2 (column 2) of
document 1, without actually opening the document, and then paste it into
table 2 of this same document. Is that possible?

Thanks again in advance.

"Jacob Skaria" wrote:

Modify the filename to suit...

Dim appWD As Word.Application
Dim docWD As Word.Document

Set appWD = CreateObject("Word.Application")
Set docWD = appWD.Documents.Open("d:\New.doc")

appWD.Visible = True

For intRow = 1 To docWD.Tables(2).Rows.Count
docWD.Tables(2).Cell(intRow, 1).Range.Text = intRow
Next

--
Jacob (MVP - Excel)


"VinceW" wrote:

The code below opens the correct document but now I would like to number the
cells in the table. The document has 2 tables both with 2 columns in them.
I would like to automatically number the cells in table column 1 of table 2.
Any help is very much appreciated.

Thank you

Dim appWD As Word.Application
Set appWD = CreateObject("Word.Application")
appWD.Documents.Open ("C:\Microsoft Office
Datafiles\Word\DailyNotes\DailyNotes " & strDate & ".doc")
appWD.Visible = True




All times are GMT +1. The time now is 11:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com