Hoping that someone can give some advice, as I've modified my code many times now trying to get the
AutoFitBehavior formatting to apply correctly. The code runs through everything as is (moves everything over and completes just fine), but the AutoFit never applies. Feel like I'm missing something that should be a simple fix, but everything I see seems to be telling me that the
objWord.ActiveDocument.Tables(1).AutoFitBehavior wdAutoFitWindow should work - I've tried it within its' own If statement where it is now, as well as moving it around and including in different places, with the same result. Any advice is greatly appreciated.
Most recent version of my code:
Sub CopyToWord() Dim objWord Dim objDoc Dim ws As Worksheet Dim Rpt As Range Application.CopyObjectsWithCells = False Set objWord = CreateObject("Word.Application") Set objDoc = objWord.Documents.Add Set ws = ThisWorkbook.Worksheets("Report") LastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row LastColumn = ws.Cells(2, ws.Columns.Count).End(xlToLeft).Column ws.Range("A1:" & Split(ws.Cells(, LastColumn).Address, "$")(1) & LastRow).Copy With objWord .ActiveDocument.PageSetup.Orientation = 1 .Selection.Paste .Visible = True End With If objWord.ActiveDocument.Tables.Count <> 0 Then objWord.ActiveDocument.Tables(1).AutoFitBehavior wdAutoFitWindow End If Application.CopyObjectsWithCells = True ThisWorkbook.Worksheets("Control Panel").Activate End Sub