+ Reply to Thread
Results 1 to 10 of 10

Alt Enter vs. Chr(13)

  1. #1
    Steve
    Guest

    Alt Enter vs. Chr(13)

    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.Caption
    txt_2= Replace(txt_1, Chr(13), " ")

    This does not work. Any ideas?

  2. #2
    Die_Another_Day
    Guest

    Re: Alt Enter vs. Chr(13)

    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.Caption
    > txt_2= Replace(txt_1, Chr(13), " ")
    >
    > This does not work. Any ideas?



  3. #3
    witek
    Guest

    Re: Alt Enter vs. Chr(13)

    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.Caption
    > txt_2= Replace(txt_1, Chr(13), " ")
    >
    > This does not work. Any ideas?


    try also chr(10) or both.

  4. #4
    Andrew Taylor
    Guest

    Re: Alt Enter vs. Chr(13)

    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.Caption
    > txt_2= Replace(txt_1, Chr(13), " ")
    >
    > This does not work. Any ideas?



  5. #5
    Tom Ogilvy
    Guest

    RE: Alt Enter vs. Chr(13)

    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.Caption
    > txt_2= Replace(txt_1, Chr(13), " ")
    >
    > This does not work. Any ideas?


  6. #6
    NickHK
    Guest

    Re: Alt Enter vs. Chr(13)

    Steve,
    Use vbLF instead, which is actually ASCII 10.

    NickHK
    P.S. ASCII 13 is vbCr.


    "Steve" <[email protected]> ¼¶¼g©ó¶l¥ó·s»D:[email protected]...
    >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.Caption
    > txt_2= Replace(txt_1, Chr(13), " ")
    >
    > This does not work. Any ideas?




  7. #7
    Steve
    Guest

    RE: Alt Enter vs. Chr(13)

    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.Caption
    > > txt_2= Replace(txt_1, Chr(13), " ")
    > >
    > > This does not work. Any ideas?


  8. #8
    Die_Another_Day
    Guest

    Re: Alt Enter vs. Chr(13)

    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.Caption
    > > > txt_2= Replace(txt_1, Chr(13), " ")
    > > >
    > > > This does not work. Any ideas?



  9. #9
    Andrew Taylor
    Guest

    Re: Alt Enter vs. Chr(13)

    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 there:

    After:
    txt_1= ActiveSheet.Shapes(SelectedShape).DrawingObject.Caption
    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.Caption
    > > > txt_2= Replace(txt_1, Chr(13), " ")
    > > >
    > > > This does not work. Any ideas?



  10. #10
    Steve
    Guest

    Re: Alt Enter vs. Chr(13)

    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" <[email protected]> ¼¶¼g©ó¶l¥ó·s»D:[email protected]...
    > >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.Caption
    > > txt_2= Replace(txt_1, Chr(13), " ")
    > >
    > > This does not work. Any ideas?

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1