0
votes

I have a large MS Word document with a lot of captions named like this: "Map X. Map title.". The problem is that the "X" are not in ascending order. I'd like to fix it running VBA macro that will replace the "X" to a right number.

I have no problem with replacing strings but I would like to know what should I replace the "X" with (what is the type of object associated with automated numbering).

The numbers will go up for every type of Caption (e.g. "Map", "Chart"), without restarting inside chapters.

1
MS Word has a build-in feature for auto-incremented Captions? Can I assume you haven't used this to create your Captions in the first place? It's available from References > Insert Caption from Word 2007.Skytunnel
Yes, there were many authors of this documents and I need to fix it through VBA. Any help with replacing "Table ?" for "Table n" would be appreciated (AFAIK it's not possible using RegExp object).syntagma
Okay, that sounds like a difficult task. Can you clarify, are you asking for help with just the auto-numbering, have you already found a way to identify your “captions”? Because I imagine we’d need to use your method of identifying them in order to count how many of the same type have already been identified for your numberingSkytunnel

1 Answers

0
votes

Okay, I found something that might help. There is a type of Field that you can add that will create a automatic number sequence for a given reference. So will we take your example above "Map X. Map title", if you can set you code to select 'X' and then follow it with...

MyRef = "Map"
Selection.Fields.Add(Selection.Range, , "SEQ " & MyRef, False).Update

Once that's done you may need to press ALT+F9, to hide/show the Field codes