+ Reply to Thread
Results 1 to 3 of 3

Thread: Removing final newline in last paragraph marker

  1. #1
    Registered User
    Join Date
    08-16-2011
    Location
    Oslo
    MS-Off Ver
    Excel 2007
    Posts
    7

    Removing final newline in last paragraph marker

    Hi there,

    I need to copy several paragraphs of text from a word document upon the pressing of a button. This text is then pasted into a website, into a text box.
    Due to the way paragraphs seem to work, when copying the last paragraph into the website text box, another line is inserted at the bottom, i.e. the last line of text is not the last line in the pasted into text box. - Hope that is clear -?
    I think it is because the paragraph character has a trailing space included in it - ? Please could someone kindly tell me how to remove this last space or perhaps its a carriage return of some type - but I dont think so.

    e.g pasted text last line

    abcdefghijkl = last line of text in website text box
    !cursor is here, where the ! mark is.

    
    Sub Select_Paragraphs() 
        Dim rngParagraphs As Range 
        Set rngParagraphs = ActiveDocument.Range( _ 
        Start:=ActiveDocument.Paragraphs(2).Range.Start, _ 
        End:=ActiveDocument.Paragraphs(16).Range.End) 
        rngParagraphs.Copy 
    End Sub
    thank you if you can help...

  2. #2
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Removing final newline in last paragraph marker

    You'd better not copy

    Sub Select_Paragraphs()
      with activedocument
       c01 = .Range(.Paragraphs(2).Range.Start,.Paragraphs(16).Range.End)
      end with
      c01=left(c01,len(c01)-1))
     
      'object.text=c01 
    End Sub



  3. #3
    Registered User
    Join Date
    08-16-2011
    Location
    Oslo
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Removing final newline in last paragraph marker

    Ahh, thank you, I haven't tried it yet, just worked it through on paper/my head, but I understand - many thanks!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0