Results 1 to 6 of 6

Setting Margins to Narrow in Word before copying table

Threaded View

  1. #1
    Registered User
    Join Date
    06-27-2013
    Location
    Va Beach
    MS-Off Ver
    Excel 2003
    Posts
    38

    Setting Margins to Narrow in Word before copying table

    I have a range in excel that I am exporting to a word document and then saving the document. The problem I have is I than have to open the file and manually change the margins to Narrow and change the table to Autofit to Content.

    I would like a way to add these into my existing code so I did not have to do it manually.

    Sub Excel_to_Word()
        Dim wrdApp As Object
        Dim wrdDoc As Object
        Dim i As Integer
        Dim fName As String
        Dim fLoc As String
        Dim supName As String
        Dim agtName As String
        Dim agtCode As String
        Dim rint As String
        Dim evDate As String
        
        supName = Range("M3")
        MsgBox ("Supervisor Name is " & supName)
        
        agtName = Range("C3")
        rint = Range("M4")
        agtCode = Range("M2")
        evDate = Format(Range("M5"), "mm-dd-yy")
        
       
        Set wrdApp = CreateObject("Word.Application")
        wrdApp.Visible = True
        Set wrdDoc = wrdApp.Documents.Add("C:\test.docx")
            With ActiveSheet
            .Range("A1:K41").Copy
            
            End With
        fName = agtCode & " QA " & rint & " " & evDate
        MsgBox ("file name is " & fName)
        fLoc = "F:\Agent Folder\" & supName & "\" & agtName & "\"
            
        MsgBox ("Path name is " & fLoc)
        wrdApp.Documents.Add.Content.PasteExcelTable False, False, True
        Application.CutCopyMode = False
        wrdApp.ActiveDocument.SaveAs Filename:=fLoc & fName
        wrdApp.Application.Quit
    End Sub
    Any help you can provide would be great.
    Last edited by ERaasio; 12-26-2013 at 10:18 AM. Reason: Forgot to setup code in tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Setting up margins for new Excel sheet
    By Moonshanta in forum Excel General
    Replies: 9
    Last Post: 09-20-2013, 12:33 AM
  2. Replies: 1
    Last Post: 02-19-2013, 07:44 PM
  3. Setting Column Width In Every Excel Table Embeded In Word
    By mgaworecki in forum Word Programming / VBA / Macros
    Replies: 10
    Last Post: 10-12-2011, 09:34 AM
  4. Macro for setting margins
    By floricita in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-14-2010, 05:03 AM
  5. Excel - allow cell margins similar to Word table cells
    By Liz Geho in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-05-2006, 02:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1