I have a macro that converts words to numbers. It pastes the results into a document. Here is the tail end of my code (the prior code uses fields to insert the “words” for numbers and the insertion is “selected” when I reach this part of the code, so it “unlinks” the fields and moves around a bookmark to delete the ~ character which I used as a location placeholder):
Selection.Fields.Unlink ‘Rather than pasting, “unlinks” field to it’s just text
With ActiveDocument.Bookmarks ‘Surrounds selected text with bookmark
.Add Range:=Selection.Range, Name:=”NumBookMark”
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.MoveLeft Unit:=wdCharacter, Count:=1 ‘Removes selected text
Selection.TypeBackspace ‘Deletes ~ character to left
Selection.GoTo What:=wdGoToBookmark, Name:=”NumBookMark” ‘Re-selects bookmarked text
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1 ‘Moves right once to de-select text
What I now need to do is check to see if the character to the right of the insertion point (which is now located just to the right of the inserted number “words” text). I tried some combination of this, but it doesn’t check if there is a space to the right of the insertion point. I don’t think I’m using the right query.
If Selection.Characters.First.Next ” ” Then ‘If char is a space ‘2012-02-20 Testing This Again
Selection.TypeText Text:=” ”
Else
GoTo SkipErrorMsg
End If
I either get an error or it skips to the errormsg. Anybody know what VBA code I need to use to determine if there is a space to the right of the insertion point? I have tried to find the answer already on the forum, but couldn’t locate anything with the searches I was trying.
Thanks!!
-Rich