Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pulling text from Auto-Numbered field.

Status
Not open for further replies.

MikeWarner

Programmer
Oct 7, 2004
7
US
I have a document where the users created a table. The first column of the table is a unique numbered field. When creating the document, they used the Numbering feature under Format.

When I try to pull the data from this cell into a macro so that I can manipulate it, the VBA code does not see this field. If I convert the row of table to text, it loses this first field.

Any ideas on how I can get the text that is in this field?

Thanks.
 
You have to dig a little to find this in Word.

Here is a sample routine that will output this value from table(1) column(2) to the Immediate window.
Code:
Sub Output_Column1_ListValue()
Dim MyTable As Table
Dim MyCell As Cell
Set MyTable = Tables(1)
For Each MyCell In MyTable.Columns(1).Cells
  Debug.Print MyCell.Range.ListFormat.ListValue
Next MyCell
Set MyCell = Nothing
Set MyTable = Nothing
End Sub

Hope this helps,
CMP

(GMT-07:00) Mountain Time (US & Canada)
 

Couple of questions -

1. How is the numbered field created?

2. Is it, by any chance, the same as (or derivable from) the row number?

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Not sure exactly what you are trying to do, but Caution's code certain will give the value of that first column.

Gerry
 
Here is how the word document was created:

They inserted a table into word. They also went under the Bullets and Numbering menu item from the format menu. They created a custom numbering scheme (Ex. "Req - #").

Now numbering scheme was used across multiple tables. At points in the document, they would restart the numbering with different text. I use the text in this field to determine what to do with the row.

Using the code that CautionMP provides above will give me the number that is being used in the field, but not the entire string, text and number.

Let me know if you need more information.
 
MikeWarner,
Sounds like you want the [tt]ListString[/tt], not the [tt]ListValue[/tt]? This will return the value that is displayed i.e.: 1), 2), 3) or i., ii., iii.

Hope this helps,
CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top