Hello, been working on automating some formatting in an excel document via an access form. My code so far is thus:
Private Sub runFiles(fileName As String, fileMonth As String)
Dim xlApp As Object
Dim xlBook As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Open "N:\Premium Research\All Data\" & fileMonth & " " & fileName & ".xls", True, False
Set xlBook = xlApp.Application.ActiveWorkBook
With xlBook.Worksheets("Premiums")
.blah blah lots of formatting code works fine
End With
xlBook.Close SaveChanges:=True
xlApp.Quit
End Sub
So as you can see this just opens the excel file specified and cuts a few rows, adds names and so forth, this runs no problem. My question is, is there a way to automate the pasting of this data set into an access table, including title rows? There are a few files and each one has a different amount of columns so I can't just specify a range of cells to copy and paste.
Any kind of help appreciated. Thanks,
Adam.
Private Sub runFiles(fileName As String, fileMonth As String)
Dim xlApp As Object
Dim xlBook As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Open "N:\Premium Research\All Data\" & fileMonth & " " & fileName & ".xls", True, False
Set xlBook = xlApp.Application.ActiveWorkBook
With xlBook.Worksheets("Premiums")
.blah blah lots of formatting code works fine
End With
xlBook.Close SaveChanges:=True
xlApp.Quit
End Sub
So as you can see this just opens the excel file specified and cuts a few rows, adds names and so forth, this runs no problem. My question is, is there a way to automate the pasting of this data set into an access table, including title rows? There are a few files and each one has a different amount of columns so I can't just specify a range of cells to copy and paste.
Any kind of help appreciated. Thanks,
Adam.