![]() ![]() 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 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |