Lists->Text and Weird Space

S

Scott Sipe

I'm converting lists to text and am running into a weird problem where
SOMETIMES a space (spacelike?) character appears.

The goal of my program is to take an AutoNumbered list like:
1. The first item
2. The second item

and turn it into plain text that looks like:

<ListItem>1.\tThe first item
<ListItem>2.\tThe second item

The code I have below does that absolutely fine. BUT, if you change the tag
(just change both instances of "<ListItem>" to something like "ListItem:"
then some weird space/not-space (it seems to be character 32, but
behaves..oddly) appears between the colon and the item number. It occurs
WHEN pasting..I just don't get it, it's very weird. Any thoughts?

thanks much,
Scott

Code below:

Sub TagLists()

Dim li As List
Dim ap As Paragraph
'
' Do the tagging
'
For Each li In ActiveDocument.Lists
For Each ap In li.ListParagraphs
ap.Range.InsertBefore "<ListItem>"
Next ap
Next li
'
' Change to text
'
ActiveDocument.ConvertNumbersToText
'
' Go re-arrange the lines
'
Selection.HomeKey Unit:=wdStory

Selection.Find.ClearFormatting

With Selection.Find
.Text = "<ListItem>"
.Forward = True
.Wrap = wdFindStop
End With
While Selection.Find.Execute
'
' Get before the "<ListItem>" tag and select to the beginning of the line
'
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend

' MsgBox "Selection = >" & Selection.Text & "<" & vbCr & _
' "Length = >" & Selection.Characters.Count & "<" & vbCr
Selection.Cut

Selection.Find.Execute

Selection.Move Count:=1
Selection.Paste
Wend


End Sub
 
S

Scott Sipe

It was some AutoCorrect feature that is now disabled, never again to be
re-enabled.

Scott
 
W

Word Heretic

G'day "Scott Sipe" <[email protected]>,

it is most likely a non-breaking space.


Scott Sipe said:
I'm converting lists to text and am running into a weird problem where
SOMETIMES a space (spacelike?) character appears.

The goal of my program is to take an AutoNumbered list like:
1. The first item
2. The second item

and turn it into plain text that looks like:

<ListItem>1.\tThe first item
<ListItem>2.\tThe second item

The code I have below does that absolutely fine. BUT, if you change the tag
(just change both instances of "<ListItem>" to something like "ListItem:"
then some weird space/not-space (it seems to be character 32, but
behaves..oddly) appears between the colon and the item number. It occurs
WHEN pasting..I just don't get it, it's very weird. Any thoughts?

thanks much,
Scott

Code below:

Sub TagLists()

Dim li As List
Dim ap As Paragraph
'
' Do the tagging
'
For Each li In ActiveDocument.Lists
For Each ap In li.ListParagraphs
ap.Range.InsertBefore "<ListItem>"
Next ap
Next li
'
' Change to text
'
ActiveDocument.ConvertNumbersToText
'
' Go re-arrange the lines
'
Selection.HomeKey Unit:=wdStory

Selection.Find.ClearFormatting

With Selection.Find
.Text = "<ListItem>"
.Forward = True
.Wrap = wdFindStop
End With
While Selection.Find.Execute
'
' Get before the "<ListItem>" tag and select to the beginning of the line
'
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend

' MsgBox "Selection = >" & Selection.Text & "<" & vbCr & _
' "Length = >" & Selection.Characters.Count & "<" & vbCr
Selection.Cut

Selection.Find.Execute

Selection.Move Count:=1
Selection.Paste
Wend


End Sub

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
Email: (e-mail address removed)
Products: http://www.geocities.com/word_heretic/products.html
Spellbooks: 728 pages of dump left and dropping...

The VBA Beginner's Spellbook: For all VBA users.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top