MsgBox "Microsoft Word file 'Excel Table Word Report.docx' is not currently open, aborting.", 16 MsgBox "Copy/Pasting Complete!", vbInformation ![]() 'Autofit Table so it fits inside Word Document MyDoc.Bookmarks(BookmarkArray(x)).Range.PasteExcelTable _ 'Paste Table into MS Word (using inserted Bookmarks -> ctrl+shift+F5) Set tbl = ThisWorkbook.Worksheets(x).ListObjects(TableArray(x)).Range 'Loop Through and Copy/Paste Multiple Excel Tablesįor x = LBound(TableArray) To UBound(TableArray) Set myDoc = WordApp.Documents("Excel Table Word Report.docx") Set WordApp = GetObject(class:="Word.Application") 'Set Variable Equal To Destination Word Document 'List of Word Document Bookmarks (To Paste To)īookmarkArray = Array("Bookmark1", "Bookmark2", "Bookmark3", "Bookmark4", "Bookmark5") (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 Option Base 1 'Force arrays to start at 1 instead of 0
0 Comments
Leave a Reply. |