HELP WITH WORK/EXCEL MACRO
I have a macro where I paste cells into a word document, but it does not
center on the page. I want the table to center with a macro. Can someone help? Here is my code: Private Sub CommandButton1_Click() Worksheets("Report").Unprotect Dim rng As Range, c As Range Set rng = Selection For Each c In rng If c.Interior.ColorIndex = 15 Then c.Interior.ColorIndex = 2 End If Next c For Each c In rng If c.Font.ColorIndex = 5 Then c.Font.ColorIndex = 2 End If Next c Range("A1:J9769").Select Selection.Copy Dim WDApp As Object Dim WDDoc As Object Dim myDocName As String myDocName = "Survey Report.doc" 'Open Word and add a new document Set WDApp = CreateObject("Word.Application") WDApp.Visible = True WDApp.Activate Set WDDoc = WDApp.Documents.Add WDDoc.Range.Paste WDDoc.Selection.tables(1).Rows.Alignment = .wdAlignRowCenter Worksheets("Report").Protect ws_exit: Application.EnableEvents = True End Sub Thank you!!!! Dan |
All times are GMT +1. The time now is 01:55 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com