My Excel addin has a feature to remove all line feeds and replace them with a space.
Originally, I had just this (and it worked fine):
However - I started coming across line feeds that weren't being removed by that code. After playing with it a bit, I ended up getting the ASCII codes for the line feeds I couldn't remove.Code:Globals.ThisAddIn.Application.ScreenUpdating = False Globals.ThisAddIn.Application.DisplayAlerts = False Globals.ThisAddIn.Application.Selection.replace(What:=vbNewLine, Replacement:=" ") Globals.ThisAddIn.Application.Selection.replace(What:=vbCr, Replacement:=" ") Globals.ThisAddIn.Application.Selection.replace(What:=vbLf, Replacement:=" ") Globals.ThisAddIn.Application.Selection.replace(What:=vbCrLf, Replacement:=" ") Globals.ThisAddIn.Application.ScreenUpdating = True Globals.ThisAddIn.Application.DisplayAlerts = True
I then altered my code to this:
This works fabulously, however it replaces all 10's, 1's, 3's, and 13's with a space as well...which is bad.Code:Globals.ThisAddIn.Application.ScreenUpdating = False Globals.ThisAddIn.Application.DisplayAlerts = False Globals.ThisAddIn.Application.Selection.replace(What:=vbNewLine, Replacement:=" ") Globals.ThisAddIn.Application.Selection.replace(What:=vbCr, Replacement:=" ") Globals.ThisAddIn.Application.Selection.replace(What:=vbLf, Replacement:=" ") Globals.ThisAddIn.Application.Selection.replace(What:=vbCrLf, Replacement:=" ") Globals.ThisAddIn.Application.Selection.replace(What:=Chr(10), Replacement:=" ") Globals.ThisAddIn.Application.Selection.replace(What:=Chr(1), Replacement:=" ") Globals.ThisAddIn.Application.Selection.replace(What:=Chr(3), Replacement:=" ") Globals.ThisAddIn.Application.Selection.replace(What:=Chr(13), Replacement:=" ") Globals.ThisAddIn.Application.ScreenUpdating = True Globals.ThisAddIn.Application.DisplayAlerts = True
Does anyone know how I can prevent the code from replacing the numbers?




Reply With Quote