

I highly recommend that you check this guide out before asking me or anyone else in the comments section to solve your specific problem. That's why I want to share with you: My Guide to Getting the Solution to your Problems FAST! In this article, I explain the best strategies I have come up with over the years to getting quick answers to complex problems in Excel, PowerPoint, VBA, you name it! We all have different situations and it's impossible to account for every particular need one might have. How Do I Modify This To Fit My Specific Needs?Ĭhances are this post did not give you the exact answer you were looking for. In order to prevent this from happening you can go ahead and use AutoFitBehavior to resize the table to fit perfectly inside your Word document. Now for the last step! Depending on how large your table is, it may be spilling outside of your document page. RTF - True pastes the Excel table using Rich Text Format (RTF).False formats the table according to the original Excel file. WordFormatting - True formats the table using the formatting in the Word document.LinkedToExcel - True links the pasted table to the original Excel file so that changes made to the Excel file are reflected in Microsoft Word.There are three variables you can tweak to get you table looking and functioning just the way you want. Word has a special method called PasteExcelTable, which (as you can guess) allows you paste in an Excel table. This can save you a bunch of time and prevent confusion!
Copy pdf info into word code#
This prevents you from having to scroll through your code and pinpoint the exact place where you spelled out which range you wanted to copy or which worksheet you wanted to pull data from. Guru Tip: It is a good idea to place code that may need to be manually changed at some point in the future near the beginning of the subroutine.

The variable tbl was used to remember this table range and to allow you to reference the range later on in the code. Near the beginning of the code, there was a line that allowed you to specify the exact table you wanted to copy. Now that you have a new document created, you can command Excel to paste your table into MS Word. WordTable.AutoFitBehavior (wdAutoFitWindow) 'Autofit Table so it fits inside Word Document MyDoc.Paragraphs(1).Range.PasteExcelTable _ MsgBox "Microsoft Word could not be found, aborting." 'Handle if the Word Application is not found If WordApp Is Nothing Then Set WordApp = CreateObject(class:="Word.Application") 'If MS Word is not already open then open MS Word Set WordApp = GetObject(class:="Word.Application") Set tbl = ThisWorkbook.Worksheets(Sheet1.Name).ListObjects("Table1").Range (VBE > Tools > References > Microsoft Word 12.0 Object Library)

'NOTE: Must have Word Object Library Active in Order to Run _ 'PURPOSE: Copy/Paste An Excel Table Into a New Word Document
