Jay Wang
Jay Wang

Reputation: 1

Change Heading Number copied from another document

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.

Upvotes: 0

Views: 179

Answers (1)

macropod
macropod

Reputation: 13515

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.

Upvotes: 1

Related Questions