Export report to excel then format it

nosferatu26

Registered User.
Local time
Today, 18:43
Joined
Jul 13, 2015
Messages
57
Hello,

I have been searching online for a while now and and im coming up dry.
I have a button in my report that when clicked, exports that report to excel and opens the file.

Here is the code for the button:
Code:
 Dim strWorkSheetPath As String
    strWorkSheetPath = "C:\Users\" & GetUserName() & "\Desktop"
    strWorkSheetPath = strWorkSheetPath & "acbPartLists.xls"
    DoCmd.OutputTo acOutputReport, "Active ACB Part Lists", acFormatXLS, strWorkSheetPath, -1
This works but ideally I want the excel sheet to be formatted a certain way to look nicer. I Then went into the excel sheet and recorded a macro of what I wanted to do for the time being and it looks like this:
Code:
 Cells.Select
    ActiveWindow.SmallScroll Down:=0
    With Selection.Font
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    Range("A3").Select
    Rows("2:2").RowHeight = 63.75
    Range("A2:F2").Select
    Selection.Font.Bold = True
    With Selection.Font
        .Name = "Arial"
        .Size = 12
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With
    Range("B7").Select
What I cant figure out is how to automatically apply code like that to the excel sheet after exporting it from access. I am relatively new to doing things like this and if anyone can help me out it would be greatly appreciated!
 

Users who are viewing this thread

Back
Top Bottom