How to "convert" all autonumber fields to plain text?

1331 views
Skip to first unread message

artur.wi...@gmail.com

unread,
Nov 11, 2013, 5:59:20 AM11/11/13
to
I'm writing a program that copies document page by page, and then saves each page as a separate file with some processing on the way. I do have problems with keeping autonumerated list number that spread across multiple pages.

Maybe it would be possible to manually open whole file before processing, and replace all number in numbered lists with their text equivalents?

To make myself clearer:
For example I have document that has a numbered header on each page:
------page1-----
1. Header I
----------------

------page2-----
2. Header II
----------------

when my program copies each page into separate files I do have :
------file1-----
1. Header I
----------------

------file2-----
1. Header II <- list number calculated automatically
----------------

It would be perfect to replace autonumbers with a plain text - is there a way to do that?

Stefan Blom

unread,
Nov 13, 2013, 4:14:14 AM11/13/13
to
You can remove number formatting using a line of code as follows. Make sure
that the document you want to "convert" is the active document. Press
Alt+F11 to display the Visual Basic Editor. Press Ctrl+G to activate the
Immediate window. Type

ActiveDocument.ConvertNumbersToText

and press Enter. This clears all auto numbers, including any LISTNUM fields,
and replaces them with static text.

Note that if you applied numbering via styles, you also have to remove the
numbering from the styles, or it may resurface (for example when you reapply
a style to text).

--
Stefan Blom
Microsoft Word MVP




<artur.wi...@gmail.com> skrev i meddelandet
news:2f89d0e0-89d2-47fc...@googlegroups.com...

susanc...@gmail.com

unread,
Mar 11, 2017, 4:03:17 PM3/11/17
to
On Wednesday, November 13, 2013 at 1:14:14 AM UTC-8, Stefan Blom wrote:
> You can remove number formatting using a line of code as follows. Make sure
> that the document you want to "convert" is the active document. Press
> Alt+F11 to display the Visual Basic Editor. Press Ctrl+G to activate the
> Immediate window. Type
>
> ActiveDocument.ConvertNumbersToText
>
> and press Enter. This clears all auto numbers, including any LISTNUM fields,
> and replaces them with static text.
>
I was using this method until today, March 11 2017, when pressing Alt/F11 no longer gets me to the VBM screen, it justs puts those annoying little black squares up in the blue ribbon. Has there been an update to Word that you know of that makes this not work anymore? Is there another way to access the VBM screen?

Thanks,
Susan

moin...@gmail.com

unread,
Jun 10, 2018, 6:23:49 AM6/10/18
to
How can I convert auto page numbers into plain text.

ActiveDocument.Range.ListFormat.ConvertNumbersToText does not work for
auto page numbers.

moin...@gmail.com

unread,
Jun 10, 2018, 6:24:34 AM6/10/18
to

Barry Schwarz

unread,
Jun 10, 2018, 12:50:15 PM6/10/18
to
The following was extracted from the Microsoft MVP web site, mvps.org.
While the macro itself does not do what you want, the introduction
provides a big clue how to do that. You might want to visit the site
for additional hints.

Copy a field code as normal text
When you need to prepare documentation that discusses field codes,
such as this web-site, it can be very tricky if you want to show
examples of field codes. Because when you copy and paste a field code,
what you normally get is not the text, but the field result! The
following two macros will copy the field you currently have selected
in your document and either insert it as text (Word 6/7) or place it
on the clipboard so that it can be pasted anywhere (Word 97). Sub MAIN
'Macro code for Word6/7
ScreenUpdating 0
CurrSetting = ViewFieldCodes()
If CurrSetting <> - 1 Then ViewFieldCodes 1
Fieldstring$ = Selection$()
NewString$ = ""
For X = 1 To Len(Fieldstring$)
CurrChar$ = Mid$(Fieldstring$, X, 1)
Select Case CurrChar$
Case Chr$(19)
CurrChar$ = "{"
Case Chr$(21)
CurrChar$ = "}"
Case Else
End Select
NewString$ = NewString$ + CurrChar$
Next X
CharRight : InsertPara
Insert NewString$
ViewFieldCodes CurrSetting
End Sub
Sub FieldCodeToString()
'Macro code for Word97
Dim Fieldstring As String, NewString As String
Dim CurrSetting As Boolean, fcDisplay As Object
Dim MyData As DataObject
NewString = ""
Set fcDisplay = ActiveWindow.View
Application.ScreenUpdating = False
CurrSetting = fcDisplay.ShowFieldCodes
If CurrSetting <> True Then fcDisplay.ShowFieldCodes = True
Fieldstring = Selection.Text
For X = 1 To Len(Fieldstring)
CurrChar = Mid(Fieldstring, X, 1)
Select Case CurrChar
Case Chr(19)
CurrChar = "{"
Case Chr(21)
CurrChar = "}"
Case Else
End Select
NewString = NewString + CurrChar
Next X
Set MyData = New DataObject
MyData.SetText NewString
MyData.PutInClipboard
fcDisplay.ShowFieldCodes = CurrSetting
End Sub


--
Remove del for email
Reply all
Reply to author
Forward
0 new messages