Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6109223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:22:50+00:00 2026-05-23T14:22:50+00:00

I have managed to copy and paste a table in word using VBA into

  • 0

I have managed to copy and paste a table in word using VBA into excel but the end result isn\t quite what I have expected.

There is this problem of a linebreak issue in some of my cells that I would like to solve.

For example,

I have a text in a table in word with certain linebreak like

“This is a sunny day and we have the following options:”

   a) Go shopping

   b) Stay Indoor

The problem with this is that once it is imported into excel, point a and b is no longer in the same cell in excel. Excel inserted it as a new cell each instead of formatting the points into a single cell.

I have tried to use find and replace to replace the linebreak ^p into blank but the letter a and b would be removed as space. I don’t want to replace my a and b as space. I still need them to be inserted into the excel cell.

Sub CreateExcel()

Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Dim tableWord As Word.Table


Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False

Set xlWB = xlApp.Workbooks.Add ' create a new workbook
'declare the cell to put the text in
With xlWB.Worksheets(1)
     Set tableWord = ActiveDocument.Tables(1)
     tableWord.Range.Copy
    .Paste Destination:=xlWB.Worksheets(1).Range("A1")

    xlApp.Dialogs(xlDialogSaveAs).Show
End With

xlWB.Close False ' close the workbook without saving
xlApp.Quit ' close the Excel application
Set xlWB = Nothing
Set xlApp = Nothing

End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:22:51+00:00Added an answer on May 23, 2026 at 2:22 pm

    You can try to search & replace with the Carriage Return character: Chr(10)

    [EDIT]
    Well, i can’t find a way to deal straight forward with your issue, maybe a better vba expert may find a solution.

    The workaround i found is to concatenate the values of the cell after you pasted them because there is no other way to keep formatting either (i adapted my Excel code to make it usable in Word vba):

    Option Explicit
    
    Sub CreateExcel()
    
    Dim xlApp As Excel.Application
    Dim xlWB As Excel.Workbook
    Dim tableWord As Word.Table
    Dim cell As Excel.Range, rUsed As Excel.Range, target As Excel.Range
    Dim val As String
    
    Set xlApp = CreateObject("Excel.Application")
    xlApp.Visible = True
    'xlApp.Visible = False
    
    Set xlWB = xlApp.Workbooks.Add ' create a new workbook
    'declare the cell to put the text in
    With xlWB.Worksheets(1)
         Set tableWord = ActiveDocument.Tables(1)
         tableWord.Range.Copy
        .Paste Destination:=xlWB.Worksheets(1).Range("A1")
    
        'Select used range to get every cell that was pasted and has content
        Set rUsed = xlWB.Worksheets(1).UsedRange
        Set target = rUsed.Cells(1, 1)
        'Get the value of each cell and concatenate its value
        For Each cell In rUsed
            If cell.Value <> "" Then
                val = val + cell.Value + Chr(10)
                cell.ClearContents
            End If
        Next cell
        'Remove last carriage return
        target.Value = Left(val, Len(val) - 1)
    
        xlApp.Dialogs(xlDialogSaveAs).Show
    End With
    
    xlWB.Close False ' close the workbook without saving
    xlApp.Quit ' close the Excel application
    Set xlWB = Nothing
    Set xlApp = Nothing
    End Sub
    

    Regards,
    Max

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have in the past successfully managed to copy/edit/paste rewrite rules on an apache
I have managed to create a custom action in C# using MakeSfxCA which is
If I have managed to locate and verify the existence of a file using
I've deconstructed a standard WPF button using Blend and have managed to create a
I have read many topics about cut/copy to clipboard, but haven't found the answer
I am using cakephp 1.3 and fancybox..I have managed to put a form in
I have been using some P/Invoke code to simulate a key press, but I
I have managed to set up Cassandra + Thrift and the Python wrapper for
I have managed to get a cron job to run a rake task by
So far I have managed to write some code that should print the source

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.