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

Problem Solved was (Re: Lists->Text...) by Scott

Scott
Mon Jul 07 06:23:20 CDT 2003

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

Scott


"Scott Sipe" <css@cap-press.com> wrote in message
news:eC5u9UFRDHA.2432@TK2MSFTNGP10.phx.gbl...
> 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
>
>



Re: Lists->Text and Weird Space by Word

Word
Fri Jul 11 22:04:05 CDT 2003

G'day "Scott Sipe" <css@cap-press.com>,

it is most likely a non-breaking space.


"Scott Sipe" <css@cap-press.com> was spinning this yarn:

>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: word_heretic@yahoo.com.au
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.