M
Marc Hankin
1. The following code is from a command button on a userform in Word2003 for
students and teachers. The code is intended to remove Title cap the
selection, and remove all spaces.
2. The problem I'm trying to address is the line: intCounter =
iStrSelektion + 1
3. When I hover the cursor (in debug mode) over iStrSelektion, I get a
value of 17.
4. But when I hover the cursor over intCounter , I get a value of 0.
What am I doing wrong?
Private Sub btnRemovSpcsNdInitCap_Click()
Me.Hide
'
Dim MyData As DataObject
Dim strClip As String
Dim strSelektion As String, strCkChar As String, strHoldChars As String
Dim iStrSelektion As Integer, intCounter As Integer
Selection.Range.Case = wdTitleWord
strSelektion = Selection
iStrSelektion = Len(strSelektion)
intCounter = iStrSelektion + 1
strCkChar = ""
strHoldChars = ""
Do While intCounter > 0
intCounter = intCounter - 1
strCkChar = Mid(strSelektion, intCounter, 1)
'MsgBox "strCkChar =" & strCkChar
If strCkChar = Chr(32) Then strCkChar = ""
If strCkChar = Chr(64) Then strCkChar = ""
If strCkChar = Chr(160) Then strCkChar = ""
strHoldChars = strHoldChars & strCkChar
Loop
'MsgBox strHoldChars
'Selection.TypeParagraph 'Hit Enter key
'Selection.EndKey Unit:=wdStory 'Ctrl-End, go to bottom
'Selection.TypeText Text:=strHoldChars
Set MyData = New DataObject
MyData.SetText strHoldChars
MyData.PutInClipboard
'
End Sub
students and teachers. The code is intended to remove Title cap the
selection, and remove all spaces.
2. The problem I'm trying to address is the line: intCounter =
iStrSelektion + 1
3. When I hover the cursor (in debug mode) over iStrSelektion, I get a
value of 17.
4. But when I hover the cursor over intCounter , I get a value of 0.
What am I doing wrong?
Private Sub btnRemovSpcsNdInitCap_Click()
Me.Hide
'
Dim MyData As DataObject
Dim strClip As String
Dim strSelektion As String, strCkChar As String, strHoldChars As String
Dim iStrSelektion As Integer, intCounter As Integer
Selection.Range.Case = wdTitleWord
strSelektion = Selection
iStrSelektion = Len(strSelektion)
intCounter = iStrSelektion + 1
strCkChar = ""
strHoldChars = ""
Do While intCounter > 0
intCounter = intCounter - 1
strCkChar = Mid(strSelektion, intCounter, 1)
'MsgBox "strCkChar =" & strCkChar
If strCkChar = Chr(32) Then strCkChar = ""
If strCkChar = Chr(64) Then strCkChar = ""
If strCkChar = Chr(160) Then strCkChar = ""
strHoldChars = strHoldChars & strCkChar
Loop
'MsgBox strHoldChars
'Selection.TypeParagraph 'Hit Enter key
'Selection.EndKey Unit:=wdStory 'Ctrl-End, go to bottom
'Selection.TypeText Text:=strHoldChars
Set MyData = New DataObject
MyData.SetText strHoldChars
MyData.PutInClipboard
'
End Sub