Try Format excel separate sheets

alwazeer

Registered User.
Local time
Today, 15:13
Joined
Nov 9, 2011
Messages
36
Hi all

How can I Format The exported to Excel file in the simple i attach??

thanks
 

Attachments

This should get you started. Create or insert this code into a module (not the form module).

Then call it from your code after the docmd.transfer spreadsheet

Code:
Sub FormatExcel(FileName As String)
'Format excel file 
    Set objapp = CreateObject("Excel.Application")
    objapp.Visible = True
    Set wb = objapp.workbooks.Open(FileName, True, False)
    'select all worksheets & cells In turn
    For Each ws In wb.worksheets
        'amend font To whatever
        With ws
            .Columns.autofit
            .Columns.Font.Name = "Arial"
            .Columns.Font.Size = 12
            .Range("A1").Select
                
        End With
    Next 'next worksheet
    wb.Save
    objapp.Quit
    Set objapp = Nothing
End Sub
 

Users who are viewing this thread

Back
Top Bottom