output results to excel

phillbaker

Registered User.
Local time
Today, 10:34
Joined
Jun 29, 2008
Messages
45
i have a database where by it runs and query depending what date is selected from the calender and then in a drop down box shows the avaliable reports.

I want to be able to import that particualr data and put it into a preformatted excel. Is this possable to do.
 
that sample does indeed work and it outputs the details i need. I have a premade form or sheet where data needs to be places in particlar places is there any of doing this i.e with bookmarks.
 
What you can do is create a form which shows the record you want to place in Excel and then have a command button that when you click it will export that record to your workbook and place the data in the relevant cells. See this example. You will have to set the References to Excel in VBA screen use Alt + F11 then go down to Microsoft Excel (a number) object library then tick the box on the left.

If it needs to go to a workbook you would have to add in the full path and file name including .xls, I have used add a book. I have coloured in Red the field names I am using on my form.

Private Sub cmdExport_Click()
Dim xlApp As Excel.Application
Set xlApp = CreateObject("Excel.Application")
With xlApp
.Workbooks.Add
.Sheets("sheet1").Select
.Range("b5").Value = Me.id.Value
.Range("B10").Value = Me.EmployeeName.Value
.Range("G10").Value = Me.PhoneNumber.Value
.Visible = True

End With

End Sub
 

Users who are viewing this thread

Back
Top Bottom