Keeping or restoring "Start at" value for heading list after updating styles from a template
I have a macro that I use quite often when other people have been working on a document I created from a template, and have messed up the styles by pasting in things from elsewhere etc: essentially it performs the steps of linking the document to the correct template, ticking the "Automatically update document styles" box, pressing ok, then going back in and unticking the box. This is my standard way to getting the style list back in order.
It falls down when I have a document where the headings don't start at 1 though, which happens when I am doing a tender with (for example) Schedules from 1-10 and they want the numbering for Schedule 3 to start at 3.1. I do this by going into the list style and setting "Start at" to "3", and so on. When I update the styles, this value is set back to 1 and I need to go in and manually change it back to what it should be.
I figured I could get my macro to do this by setting a variable with the current value of "Startat", perform the linking/updating steps, then set it back with the value in the variable. My knowledge of VBA is quite poor: below is my current macro with a lame attempt at new code in blue (which obviously doesn't work) and in red explaining what I want to do: I'm hoping someone can suggest the correct code!
------
Sub ScheduleUpdateStylesFromTemplate()
'
Dim x as long (??)
Set x = ListGalleries(wdOutlineNumberGallery).ListTemplate s(1).ListLevels(1).StartAt
Here I want to set the variable "x" with the current value of "StartAt" for my "Numbered Headings" List Style, so I think I also need to reference that the list style is "Numbered Headings" somewhere??
With ActiveDocument
.UpdateStylesOnOpen = True
.AttachedTemplate = _
"Y:\RFT Template.dotx"
End With
With ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = _
"Y:\RFT Template.dotx"
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplate s(1).ListLevels(1)
.StartAt = x
End With
Here I want to set the "StartAt" value for "Numbered Headings"to be the value of "x" that I captured before I refreshed the styles
End Sub
|