Link to home
Start Free TrialLog in
Avatar of ajakeway
ajakeway

asked on

Linking styles and numbering using VBA

I have about 30 templates where I want to, using VBA, ensure that they have a consistent user-defined style and numbering format.  I managed to get the font and sizing correct for the style, but the numbering seems to be a separate beast.  Can anyone supply VBA code that says, "when I apply this style, use this numbering".  Basically, like how it works when you use the built-in "Header1" or "Header2" style format.  But for me in a custom style.

Thanks!
Avatar of Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Flag of New Zealand image

Hello,

why don't you include the numbering in the style definition?

cheers, teylyn
Avatar of ajakeway
ajakeway

ASKER

Teylyn,

I would love to.  I have spent two days searching online for how to do so.  Can you provide any code or website that might guide me on this?  Unfortunately the macro recorder hasn't helped me with this either.

Alex
Modify the style and select a numbering format.

Or are you defining the styles from scratch in VBA? If so, why? You might consider creating templates with the styles already defined and create documents based on these templates. Then the styles and their numbering will be in place without any VBA involvement.
Because I am modifying templates, I thought it best to define the styles from scratch in VBA.  That way there would be consistency between the templates, and I could use VBA to open each template, apply the required style (and numbering scheme) and then save the template.  I could do so manually, but I foresee us taking this approach for other documents (and templates) as well, so if possible, doing it via VBA would be nicer.
ASKER CERTIFIED SOLUTION
Avatar of Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
my apologies, I got tied up with kids duty and then other work became a priority.

As for this... I tried the suggested VBA and it would work in one template but not another.  I believe this is because of differences between the numbering formats in the various templates.  With the reply above and the various other online sources detailing how numbering lists work and the rather, uh, ingenious ways that WORD handles them and styles, I have decided to try approaching this from another way.  If I find a solution, I will post it.  For now, the question is deemed closed.
Considering the complexity of styles and numbering lists in Word, the solution provided appropriate guidance.  Ultimately I will need to take a different approach.