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
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