Exporting query fields to specific Excel cells

TUSSFC

Registered User.
Local time
Today, 14:05
Joined
Apr 12, 2007
Messages
57
Is this possible?

I have a query which gives 5 fields.
I have an excel file formatted with a specific layout and 5 empty cells for the query results.

Is there any VBA I can use to copy the query data to those specific cells on the fly???

v: Office 03
 
You can open the spreadsheet in Access and do as you please. Here is a pc of sample code:


Code:
Dim xlApp As Excel.Application
         Dim xlBook As Excel.Workbook
         Dim xlSheet As Excel.Worksheet
         Set xlApp = CreateObject("Excel.Application")
         Set xlBook = xlApp.Workbooks.Add
         Set xlSheet = xlBook.Worksheets("Sheet1")
         xlSheet.Range(Cells(1, 1), Cells(10, 2)).Value = "Hello"
         xlBook.Saved = True
         Set xlSheet = Nothing
         Set xlBook = Nothing
         xlApp.Quit
         Set xlApp = Nothing

(You have to have excel references set)
 

Users who are viewing this thread

Back
Top Bottom