Results 1 to 3 of 3

Thread: Populate Excel Problem

  1. #1

    Thread Starter
    Hyperactive Member doctrin13th's Avatar
    Join Date
    Sep 2008
    Posts
    303

    Populate Excel Problem

    Populating a worksheet with text from a single line textbox, that I got working.
    But whenever I put contents to a cell from a multiline textbox or even a richtextbox, the newline character turns into a square. Same with Tab.
    How can I prevent the program putting ascii characters instead of the actual carriage return(Enter key) or the tab key?

    is there a way?

  2. #2
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: Populate Excel Problem

    1. Tab character cannot be displayed in a cell --> Tab turns to square
    2. Line break in Excel cell use vbLf = Chr(10) while line break in Textbox use vbCrLf = Chr(13) & Chr(10) --> Chr(13) turns to square
    You also need to turn on Wrap Text for the cell.

    Some thing like:
    Code:
    ws.Range("A1") = Replace(Replace(Text1.Text, vbCrLf, vbLf), vbTab, " ")
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Populate Excel Problem

    Moved To Office Development

Posting Permissions

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



Click Here to Expand Forum to Full Width