PDA

View Full Version : Simple start of word list at #1



brent.fraser
01-08-2014, 04:05 PM
I have an excel file that I am importing information into a word document. Everything is working well except one thing:

I have lists that gets put into a content control and the information is working well. I have 5 content controls in a row and the first two start the numbering at 1 but that last one continues the numbering from the previous list (and I have no idea why). Here's an example:




CAD Support


Person 1
Person 2
Person 3





Office Services


Person 1




Technical Writing

2. Person 1




Is there a way to select the content control and have it start at 1?

The code I have is as follows:

For Each R In workbook.Worksheets("Technical Writing").Range("manpower")
If R.Value <> "" Then
technicalWritingManpower = technicalWritingManpower & R.Value & vbLf
End If
Next
Dim oCC_technicalWritingManpower As ContentControl

If technicalWritingManpower = "" Then
Set oCC_technicalWritingManpower = ActiveDocument.SelectContentControlsByTitle("technicalWritingManpower").Item(1)
oCC_technicalWritingManpower.Range.Text = "The group has no current manpower"
oCC_technicalWritingManpower.Range.Font.Color = wdColorGray50
Else
Set oCC_technicalWritingManpower = ActiveDocument.SelectContentControlsByTitle("technicalWritingManpower").Item(1)
oCC_technicalWritingManpower.Range.Text = Left(technicalWritingManpower, Len(technicalWritingManpower) - 1)
oCC_technicalWritingManpower.Range.Font.Color = wdColorBlack
oCC_technicalWritingManpower.Range.ListFormat.ApplyOutlineNumberDefault
End If

I am basically putting it that if the excel sheet has a value in it, put it in a numbered list. The issue is that the last list starts at 2 and not one. I can go in manually to restart the list at 1 but there should be a way I can reset it using VBA.

Thx everyone.
Brent

macropod
01-08-2014, 08:44 PM
It seems to me that what your prefix numbering describes is Word's paragraph numbering, which has nothing to do with any numbering of the content controls. It would be easier to understand what the issues is if you attached a document to a post. You can do this via the paperclip symbol on the 'Go Advanced' tab.

brent.fraser
01-09-2014, 09:02 AM
Hi there,

Here are both documents (word and excel) that make up the report.

You are right, it is the paragraph numbering that is inside the content control that is the issue. I can go in after the fact and select "restart numbering" but I thought there would be a way to reset it using vba.

Brent