View Single Post
 
Old 09-25-2015, 04:56 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Change:
Code:
          'Paste Table into MS Word (using inserted Bookmarks -> ctrl+shift+F5)
          .Bookmarks(BookmarkArray(x)).Range.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False, RTF:=False
          .Bookmarks(BookmarkArray(x)).Range.tables(1).autofitbehavior (2)

          'This block of comments is my trying to get the line above (autofitbehavior) to work with both pasted tables:
          'Set BMRange = .Bookmarks(BookmarkArray(x)).Range
          'BMRange.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False, RTF:=False
          '.Bookmarks.Add BookmarkArray(x), BMRange
          '.Bookmarks(BookmarkArray(x)).Range.Select  'autofitbehavior (2)
to:
Code:
         'Paste Table into MS Word & format
        With myDoc.Bookmarks(BookmarkArray(x)).Range
          .PasteExcelTable LinkedToExcel:=False, WordFormatting:=False, RTF:=False
          .MoveEnd wdTable, 1
          .Tables(1).AutoFitBehavior (wdAutoFitWindow)
        End With
PS: When posting the code at VBAX, please credit this site with the above and provide a link to this thread.
PPS: snb has a long-established reputation, both a VBAX and elsewhere, for posting code that doesn't actually address the user's needs.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote