Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-09-2019, 03:46 PM
macropod's Avatar
macropod macropod is offline Returns in Word table text become multiple rows when pasted in Excel Windows 7 64bit Returns in Word table text become multiple rows when pasted in Excel Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,526
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


If you're wedded to having the data in Excel, you could use a macro like:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim xlObj As Object, xlWkBkObj As Object
With Selection.Tables(1).Range
  'Pre-format the table
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[^13^l]"
    .Replacement.Text = Chr(182)
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
  'Copy the table
  .Copy
End With
ActiveDocument.Undo
'Start Excel if not running
On Error Resume Next
Set xlObj = GetObject(, "Excel.Application")
' Start Excel if it isn't running
If xlObj Is Nothing Then Set xlObj = CreateObject("Excel.Application")
With xlObj
  'Add a workbook
  Set xlWkBkObj = .Workbooks.Add
  With xlWkBkObj.Sheets(1)
  'Paste the data
    .Paste '.Range("A1")
    'Post-format the data
    With .UsedRange
      .HorizontalAlignment = 1 'xlGeneral
      .WrapText = False
      .Columns.AutoFit
      .Replace Chr(182), Chr(10)
      .Columns.AutoFit
      .Rows.AutoFit
    End With
  End With
  .CutCopyMode = False
  .Visible = True
End With
Application.ScreenUpdating = True
End Sub
For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
For Mac macro installation & usage instructions, see: https://wordmvp.com/Mac/InstallMacro.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
enter, filename as document text, insert column, paste, rows, vba in word



Similar Threads
Thread Thread Starter Forum Replies Last Post
a table pasted in word from excel is not similar to the original table in excel Mukapa Word Tables 1 01-18-2016 07:31 AM
Modify a just-pasted Excel table p45cal Word VBA 2 09-26-2015 01:02 PM
Excel Multiple Rows Merged into Word (Vertical Format) ats1025 Mail Merge 3 11-19-2013 02:21 PM
Returns in Word table text become multiple rows when pasted in Excel Add multiple rows to Excel 2010 table at cursor position C J Squibb Excel Programming 12 11-07-2013 07:35 AM
connectors between cells in pasted Excel table eNGiNe Word 7 10-16-2013 11:58 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:35 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft