0
votes

How can I change the Heading Number with VBA code?

For example, "1.1 Computer system"
I'd like to change "1.1" to "1.2".

I can read it with:

Selection.Paragraphs(1).Range.ListFormat.ListString

I can't find a way to change it.

  1. Basic Function Test

1.1. LED Function Test Purpose: To make sure all the LED Functions are working as the Product Specification Resource Requirements:

The context is shown above. Sometimes, I copy from another document. The pasted heading number is not correct.

I tried to record the macro but the recorded macro is empty.

1
Is it possible provide some "context" or a sample document? This will assist anyone who might be able to help you.Andrew Truckle
Did you try recording a macro when you do this manually?freeflow

1 Answers

1
votes

To force Heading 2 to start the numbering from 1.2, all you need is:

ActiveDocument.Styles(wdStyleHeading2).ListTemplate.ListLevels(2).StartAt = 2

Your update shows you're trying to do something quite different, however.

The only reliable way to retain the original numbering when copying/pasting between documents is to either:

  • convert the source numbering to static text before copying; or
  • paste the copied content as unformatted text.