Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Jun 2003
    Location
    St. Louis, MO
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Paste Word Text in Cell (Office 97)

    How can I paste data from Word into an Excel cell using VBA without losing formats? The manual operation which works is:
    1. copy text from Word (including tabs and line breaks)
    2. Double click on a worksheet cell (cursor now is blinking in cell).
    3. press CTRL-V to paste text.

    When this is executed manually, tabs and line breaks are preserved. When I try in VBA, the text is either spread across several cells or contains little blocks where tabs and line breaks are. I have tried several different paste, pastespecial, and getfromclipboard methods with no success.

  2. #2
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Paste Word Text in Cell (Office 97)

    MarlonF

    I could not get your manual procedure to work between MS-Word 97 and MS-Excel 97?! How do you copy including tabs and line breaks in MS-Word?

    I am not sure you can copy formats across applications, but if your manual process is working, then I stand corrected...

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Paste Word Text in Cell (Office 97)

    I would have thought the better way to insert large chunks of text that need to be formatted into XL would be to put it in a text box?

    On a similar subject, can anyone tell me how to insert a line break in an XL cell? I have several places where the entry is too long and I get just one or two words on a second line; I would much prefer to break the line manually, sooner, but can't work out how!

    Many thanks!
    Beryl M


  4. #4
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Paste Word Text in Cell (Office 97)

    Type Alt+Enter to create a line break within a cell
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  5. #5
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Darkest Kent, UK., Kent, England
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Paste Word Text in Cell (Office 97)

    Hi Beryl,

    It would appear 'Alt-Enter' in the cell does the trick.

  6. #6
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Maidstone, Kent, England
    Posts
    398
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Paste Word Text in Cell (Office 97)

    In a similar problem I had to use SendKeys to do the paste to avoid format problems. This is not a good solution though as SendKeys can be unpredictable at times


    HTH

    Peter

  7. #7
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Paste Word Text in Cell (Office 97)

    <pre></pre>

    What you probably need to do is:<UL><LI>replace your tabs and line breaks with special characters while the text is in Word - "xx" and "zz" respectively, for example;<LI>then go through the cell contents, once you've pasted it into Excel, and replace the "xx" and "zz" with their ASCII equivalents.[/list]Bit late here at the moment. If no one else has posted, I'll see if I can offer some code in the morning. If you sort it yourself, it would be a good future referenceif you could post your code. HTH
    Gre

Posting Permissions

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