Hi Stephan
Nobody seems to have answered this so I am replying to say there is somebody out here!
I understand from your description that you have a separate worksheet for each customer bill. This is a nightmare scenario (which is probably why nobody has replied!), so my first suggestion is why don't you write a new app in Access and start over!?!
Nevertheless, just listing the steps I would take to build such an app;-
You need a database with at least one table to recieve the data.
You will need a form which needs a field for the location of the latest folder, assuming you can enter this at the end of a month and then click to run a procedure to import the data. You could add a Common Dialog box to help browse and find this folder.
You need to write a procedure which will loop through the files in the folder. As a start I would just display each file name in a message box to ensure they were being read. You can use the Dir() function recursively (loop untill Dir = "", read Help on Dir Function) and it will find the next file, next file etc..
Once I was sure I was finding each file I would try opening it. The following 'snippets' could probably be used in your program
-
Dim xcel As Object
-
Set xcel = CreateObject("Excel.Application")
-
-
'Open spreadsheet,
-
xcel.workbooks.Open "NextFileName"
-
xcel.Visible = False
-
-
'Select Sheet
-
xcel.Sheets("Sheet1").Select
-
-
' Read data from cells into fields of recorset
-
!CustName = xcel.Range("A2").Value
-
!AccNo = xcel.Range("C3").Value
-
!ODate = xcel.Range("D4").Value
-
'etc
NextFileName would be the full path + filename including .wks to the current spreadsheet.
You would need to setup a recordset outside the loop and open it so you can write data to the fields you require. (I have not shown setting up the recordset but !CustName is obiously the field for the Customer Name in the recordset you are using)
"A2","C3", "D4" are just my arbitary names for the cells in the spreadsheet template that hold the data you require to extract.
I have not attempted to write the loops, within loops, within loops that are needed for this exercise but having given it a bit of thought it is quite 'do-able' (which is more than I thought at the begining)
I hope this helps a little !
S7