I added the StripCharsfunction to this module; it is called throughout the add-in to remove
various characters and spaces from control names during renaming, so as prevent problems when
the controls are referenced in code. I modified the standard template AddInErrprocedure
slightly; it creates a message box string that is called from error handlers in the add-in. The
SharedCode module that contains these procedures is listed next:
Option ExplicitPublic Function StripChars(strText _
As String) As String
Strips a variety of non-alphanumeric characters from a text string.
On Error GoTo ErrorHandlerDim strTestString As String
Dim strTestChar As String
Dim lngFound As Long
Dim i As Integer
Dim strStripChars As StringstrStripChars = “ `~!@#$%^&*()-_=+[{]};:’,<.>/?” _
& Chr$(34) & Chr$(13) & Chr$(10)
strTestString = strTexti = 1
Do While i <= Len(strTestString)Find a strippable character.
strTestChar = Mid$(strTestString, i, 1)
lngFound = InStr(strStripChars, strTestChar)
If lngFound > 0 Then
strTestString = Left(strTestString, i - 1) _
& Mid(strTestString, i + 1)
Else
i = i + 1
End If
LoopStripChars = strTestStringErrorHandlerExit:
Exit FunctionErrorHandler:
AddInErr Err
Resume ErrorHandlerExitEnd FunctionCreating COM Add-ins with Visual Basic 6 13