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 7064723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:52:10+00:00 2026-05-28T04:52:10+00:00

Im trying to copy and paste a table from excel into a word document.

  • 0

Im trying to copy and paste a table from excel into a word document.

I can do it manually – highlight the cell, CTRL+C, go to word, CTRL+V. it works fine.

But when I write a macro to do it the cells are twice the height, like the line height in each cell gets changed for some reason. why is it different? I recorded the manual procedure and it is the same function (PasteExcelTable) being called.

Set wordDoc = wordApp.Documents.Open(wordDocPath)

With wordDoc
    ' cost report
    Dim wordRng As Word.Range
    Dim xlRng As Excel.Range
    Dim sheet As Worksheet
    Dim i As Integer
    Dim r As String

    'Copy the cost report from excel sheet
    Set sheet = ActiveWorkbook.Sheets("COST REPORT")
    i = sheet.Range("A:A").Find("TOTAL PROJECT COST", Range("A1"), xlValues, xlWhole, xlByColumns, xlNext).row
    r = "A11:M" + Trim(Str(i))

    Set xlRng = sheet.Range(r)
    xlRng.Copy

    'Copy and Paste Cost report from Excel
    Set wordRng = .Bookmarks("CostReport").Range 'remember original range

    If .Bookmarks("CostReport").Range.Information(wdWithInTable) Then
        .Bookmarks("CostReport").Range.Tables(1).Delete
    End If

    .Bookmarks("CostReport").Range.PasteExcelTable False, False, False
    .Bookmarks.Add "CostReport", wordRng    'reset range to its original positions
End With
  • 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-28T04:52:10+00:00Added an answer on May 28, 2026 at 4:52 am

    Here is my solution:

    With wordDoc
        'Paste table from Excel
        Set wordRng = .Bookmarks(bookMarkName).range 'remember original range
    
        If .Bookmarks(bookMarkName).range.Information(wdWithInTable) Then
            .Bookmarks(bookMarkName).range.Tables(1).Delete
        End If
    
        .Bookmarks(bookMarkName).range.PasteExcelTable False, False, False
        .Bookmarks.Add bookMarkName, wordRng    'reset range to its original positions
    
        Dim paraFmt As ParagraphFormat
        Set paraFmt = .Bookmarks(bookMarkName).range.Tables(1).range.ParagraphFormat
    
        paraFmt.SpaceBefore = 0
        paraFmt.SpaceBeforeAuto = False
        paraFmt.SpaceAfter = 0
        paraFmt.SpaceAfterAuto = False
        paraFmt.LineSpacingRule = wdLineSpaceSingle
        paraFmt.WidowControl = True
        paraFmt.KeepWithNext = False
        paraFmt.KeepTogether = False
        paraFmt.PageBreakBefore = False
        paraFmt.NoLineNumber = False
        paraFmt.Hyphenation = True
        paraFmt.OutlineLevel = wdOutlineLevelBodyText
        paraFmt.CharacterUnitLeftIndent = 0
        paraFmt.CharacterUnitRightIndent = 0
        paraFmt.CharacterUnitFirstLineIndent = 0
        paraFmt.LineUnitBefore = 0
        paraFmt.LineUnitAfter = 0
        paraFmt.MirrorIndents = False
        paraFmt.TextboxTightWrap = wdTightNone
        paraFmt.Alignment = wdAlignParagraphLeft
    
        .Bookmarks(bookMarkName).range.Tables(1).AutoFitBehavior (wdAutoFitWindow)
    
    End With
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to copy an excel Table and image from MS EXCEL to
I am trying to solve copy pasting a column with values from excel into
I am trying to copy data from my MYSQL table to SQL Server using
Basically, I'm trying to selectively copy a table from one database to another. I
I'm trying to copy a custom object from a RDC window into host (my
I've got a table in a word document which I'm trying to add a
I'm trying to create a copy/paste system for a HTML table using jQuery and
I was trying the TabLayout Tutorial from official developers site. I didnt copy paste
i am trying to get a chat working that is a copy paste from
I'm trying to compress any given string to a shorter version, copy paste-able compressed

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.