Indent table pasted from Excel into Word

0 votes

How can I indent a table that was copied from Excel into Microsoft Word? What might be wrong with my present code to cause an error?

I tried using rngPara.Indent. My present code scans an Excel range for "Cases," pulls them out, and produces a Word document for each Case. Pastes table5 Case "table5" in the current case.

A part from my current code for copy-pasting Excel table:

   Dim wdRngPL As Object 'Word.Range
   Set wdRngPL = .Range.Characters.Last
    Case "table5"
      ThisWorkbook.Sheets("Pricelist").Range("B31:D681").Copy
        With wdRngPL
        Set rngPara = .Paragraphs.Last.Range
        rngPara.Style = "Attachment"
        rngPara.PasteExcelTable False, False, False
        '.Tables(.Tables.Count).AutoFitBehavior wdAutoFitWindow
        .Font.Hidden = 0
        rngPara.Indent
        Set rngPara = Nothing
        End With

I want to simulate manual work. If I remove rngPara.Indent then my process goes like this. The table is getting pasted to Word from Excel. I have to go to the Word document select my table and hit Increase Indent one time.

Oct 30, 2022 in Others by Kithuzzz
• 38,000 points
562 views

1 answer to this question.

0 votes
It is feasible to pick up the Table object directly because the table is being pasted at the end of a Range: From that point, get the table's range and apply the desired formatting:

I hope this helps you.
answered Oct 30, 2022 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

How to import data from a HTML table on a website to excel?

Hello  To import any HTML file in excel there ...READ MORE

answered Feb 10, 2022 in Others by gaurav
• 23,260 points
7,981 views
0 votes
1 answer

Exporting a table from Amazon RDS into a CSV file

Presumably, you're attempting to export data from ...READ MORE

answered Mar 3, 2022 in Others by gaurav
• 23,260 points
2,478 views
0 votes
1 answer

Excel: How to merge two columns into one (from different sheets or separated columns)

This equation is completely adjustable. Your two ...READ MORE

answered Oct 7, 2022 in Others by narikkadan
• 63,600 points
887 views
0 votes
1 answer

Data entry into web page from excel

Reading the File in PHP Example 1 How to ...READ MORE

answered Oct 10, 2022 in Others by narikkadan
• 63,600 points
1,207 views
0 votes
1 answer

How can I find and replace text in Word using Excel VBA?

Try this code Option Explicit Const wdReplaceAll = 2 Sub ...READ MORE

answered Oct 15, 2022 in Others by narikkadan
• 63,600 points
5,016 views
0 votes
1 answer

Multiple find and replace in MS Word from a list in MS Excel

If I understand you correctly, you want ...READ MORE

answered Oct 28, 2022 in Others by narikkadan
• 63,600 points
761 views
0 votes
1 answer

Word Mail Merge with Excel data has to be saved in different files with custom names

Try this: Public Sub Mail_Merge() On Error GoTo ErrH Dim ...READ MORE

answered Nov 6, 2022 in Others by narikkadan
• 63,600 points
1,815 views
0 votes
1 answer

Trouble pasting a Word equation into Excel

Use this: Sub ExpandEqn(MyText As String) ...READ MORE

answered Nov 21, 2022 in Others by narikkadan
• 63,600 points
496 views
0 votes
1 answer

Trying to create an enclosing bookmark after pasting a picture from Excel into Word using VBA

Try this: Sub IMPORT_TO_WORD() Dim ws1 As Worksheet, ws2 ...READ MORE

answered Oct 30, 2022 in Others by narikkadan
• 63,600 points
887 views
0 votes
1 answer

Copy Text from Range in Excel into Word Document

Here are some articles that may help: Control ...READ MORE

answered Nov 6, 2022 in Others by narikkadan
• 63,600 points
555 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP