Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to update a column in a work based on another work sheet WickerMan New Users to Excel 1 December 4th 09 12:58 PM
Using a macro to work from Excel to Outlook Andrew Excel Programming 2 July 14th 05 10:40 PM
Excel problem - why won't my macro work? madbloke Excel Programming 11 September 22nd 04 02:19 PM
Macro doesn't work in Excel 97 anthony Excel Programming 3 August 27th 04 02:15 AM
Macro: Excel 2000 does not work, XP does... Martin Eckart Excel Programming 5 February 2nd 04 09:56 PM


All times are GMT +1. The time now is 01:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"