Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have entered text into an autoshape and used "Alt-Enter" as CR/LF while
inputting the text. Now reading that text thru vba, I'm trying to replace the Alt_Enter (shows up as a square in my text string) with a space by using; txt_1= ActiveSheet.Shapes(SelectedShape).DrawingObject.Ca ption txt_2= Replace(txt_1, Chr(13), " ") This does not work. Any ideas? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try Chr(10), this is a line feed. or try Chr(13) & Chr(10), or try
vbCrLf Charles Steve wrote: I have entered text into an autoshape and used "Alt-Enter" as CR/LF while inputting the text. Now reading that text thru vba, I'm trying to replace the Alt_Enter (shows up as a square in my text string) with a space by using; txt_1= ActiveSheet.Shapes(SelectedShape).DrawingObject.Ca ption txt_2= Replace(txt_1, Chr(13), " ") This does not work. Any ideas? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Steve wrote:
I have entered text into an autoshape and used "Alt-Enter" as CR/LF while inputting the text. Now reading that text thru vba, I'm trying to replace the Alt_Enter (shows up as a square in my text string) with a space by using; txt_1= ActiveSheet.Shapes(SelectedShape).DrawingObject.Ca ption txt_2= Replace(txt_1, Chr(13), " ") This does not work. Any ideas? try also chr(10) or both. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Instead of Chr(13) you need to use Chr(10), or
equivalently (and preferably, IMHO) vbLf Andrew Steve wrote: I have entered text into an autoshape and used "Alt-Enter" as CR/LF while inputting the text. Now reading that text thru vba, I'm trying to replace the Alt_Enter (shows up as a square in my text string) with a space by using; txt_1= ActiveSheet.Shapes(SelectedShape).DrawingObject.Ca ption txt_2= Replace(txt_1, Chr(13), " ") This does not work. Any ideas? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try:
txt_2= Replace(txt_1, vbCrLf, " ") If that isn't it, then try replacing chr(13) with chr(10) -- Regards, Tom Ogilvy "Steve" wrote: I have entered text into an autoshape and used "Alt-Enter" as CR/LF while inputting the text. Now reading that text thru vba, I'm trying to replace the Alt_Enter (shows up as a square in my text string) with a space by using; txt_1= ActiveSheet.Shapes(SelectedShape).DrawingObject.Ca ption txt_2= Replace(txt_1, Chr(13), " ") This does not work. Any ideas? |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the quick replies, unfortunately, none of them worked. Forget I
said CR/LF. I guess what I need to know is how can I replace whatever special code an "Alt Enter" generates with a space? "Tom Ogilvy" wrote: Try: txt_2= Replace(txt_1, vbCrLf, " ") If that isn't it, then try replacing chr(13) with chr(10) -- Regards, Tom Ogilvy "Steve" wrote: I have entered text into an autoshape and used "Alt-Enter" as CR/LF while inputting the text. Now reading that text thru vba, I'm trying to replace the Alt_Enter (shows up as a square in my text string) with a space by using; txt_1= ActiveSheet.Shapes(SelectedShape).DrawingObject.Ca ption txt_2= Replace(txt_1, Chr(13), " ") This does not work. Any ideas? |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
txt_2= Replace(txt_1, vbLf, " ")
seems to work for me. Charles Steve wrote: Thanks for the quick replies, unfortunately, none of them worked. Forget I said CR/LF. I guess what I need to know is how can I replace whatever special code an "Alt Enter" generates with a space? "Tom Ogilvy" wrote: Try: txt_2= Replace(txt_1, vbCrLf, " ") If that isn't it, then try replacing chr(13) with chr(10) -- Regards, Tom Ogilvy "Steve" wrote: I have entered text into an autoshape and used "Alt-Enter" as CR/LF while inputting the text. Now reading that text thru vba, I'm trying to replace the Alt_Enter (shows up as a square in my text string) with a space by using; txt_1= ActiveSheet.Shapes(SelectedShape).DrawingObject.Ca ption txt_2= Replace(txt_1, Chr(13), " ") This does not work. Any ideas? |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Actually I'm confused about this: Alt-Enter is used to create line
breaks in a Cell. but your text is in a Shape, where line breaks are created by Enter or Ctrl-Enter. I think you need to find exactly what characters you've got the After: txt_1= ActiveSheet.Shapes(SelectedShape).DrawingObject.Ca ption Add this: Dim i as Integer, c as String For i = 1 to Len(txt_1) c = mid(txt_1,i,1) Debug.Print "Character " & i & " is Chr( " & Asc(c) & ")" Next and see what you get.. Steve wrote: Thanks for the quick replies, unfortunately, none of them worked. Forget I said CR/LF. I guess what I need to know is how can I replace whatever special code an "Alt Enter" generates with a space? "Tom Ogilvy" wrote: Try: txt_2= Replace(txt_1, vbCrLf, " ") If that isn't it, then try replacing chr(13) with chr(10) -- Regards, Tom Ogilvy "Steve" wrote: I have entered text into an autoshape and used "Alt-Enter" as CR/LF while inputting the text. Now reading that text thru vba, I'm trying to replace the Alt_Enter (shows up as a square in my text string) with a space by using; txt_1= ActiveSheet.Shapes(SelectedShape).DrawingObject.Ca ption txt_2= Replace(txt_1, Chr(13), " ") This does not work. Any ideas? |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Steve,
Use vbLF instead, which is actually ASCII 10. NickHK P.S. ASCII 13 is vbCr. "Steve" ... I have entered text into an autoshape and used "Alt-Enter" as CR/LF while inputting the text. Now reading that text thru vba, I'm trying to replace the Alt_Enter (shows up as a square in my text string) with a space by using; txt_1= ActiveSheet.Shapes(SelectedShape).DrawingObject.Ca ption txt_2= Replace(txt_1, Chr(13), " ") This does not work. Any ideas? |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you everyone. The "vbLf" did the trick. I must have typo'd the first
time I tried it. I just used Alt-Enter out of habit when typing in the shapes. Also, Thanks Andrew for the debug code. "NickHK" wrote: Steve, Use vbLF instead, which is actually ASCII 10. NickHK P.S. ASCII 13 is vbCr. "Steve" ... I have entered text into an autoshape and used "Alt-Enter" as CR/LF while inputting the text. Now reading that text thru vba, I'm trying to replace the Alt_Enter (shows up as a square in my text string) with a space by using; txt_1= ActiveSheet.Shapes(SelectedShape).DrawingObject.Ca ption txt_2= Replace(txt_1, Chr(13), " ") This does not work. Any ideas? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to select cells in column enter data then press enter | New Users to Excel | |||
Enter multiple numbers in a cell so total shows when enter keypres | Excel Worksheet Functions | |||
Enter info in one sheet, auto enter in another based on one field | New Users to Excel | |||
Auto enter date when data in enter in another cell | Excel Worksheet Functions | |||
What does hitting Ctrl + Shift + Enter to enter a formula do??? Help a n00b out. | Excel Worksheet Functions |