Transfering Spreadsheet

Ack

New member
Local time
Today, 11:21
Joined
Apr 10, 2000
Messages
6
I'm trying to copy a recordset to excel and format the spreadsheet from within Access. I have a problem because my recordset is a query which has fields whose parametes are controled from a form using combos. It gives me an error running the code that I have too few parameters, 5 expected.
Below is the start of the code.

Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Dim ObjSht As Excel.Worksheet
Dim db As Database
Dim rs As Recordset
Dim Sheet1 As Excel.Worksheet
Dim Strsql As String

Dim PathAndFileName, WorksheetName, NameofNamedRange, iFirstRow

Set db = CurrentDb
Set objXL = New Excel.Application

Strsql = "A ESM by line number query"

Set rs = db.OpenRecordset(Strsql, dbOpenSnapshot)
With objXL
.Visible = True
 
Hi Paul,

Regarding moving a recordset to Excel and formatting it from Access, I have a module that does this very thing, but it's at my work, so if you haven't got your answer by Monday, drop me a line at sstandish@classifiedventures.com anytime between 9a-5p (Chicago time) and I'll be glad to send the code to you in an email.

Incidentally, formatting the spreadsheet from Access may not be the best use of resources. If the format may be different each time you run the module, then it's worth the effort; but if it's going to be the same each time (a report), then you should just create a template spreadsheet and save the original where it won't be tampered with.

It isn't clear from your post exactly where the error is occurring, but I think it may be easier if you look at a working script, and then you can ask me questions if you need.
 

Users who are viewing this thread

Back
Top Bottom