Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Excell VBA
Excell VBA
Resolved · Medium Priority · Version 2003
Louise has attended:
Excel VBA Intro Intermediate course
Excell VBA
Is there simple code to link to Access from an Excell module?
For upcoming training course dates see: Pricing & availability
RE: Excell VBA
Hi Louise,
Thank you for your question.
The code below should allow you to import data from an access table into excel.
Dim strExcelFile As String
Dim strWorksheet As String
Dim strDB As String
Dim strTable As String
Dim objDB As Database
strExcelFile = "E:\CSC\LDMS\LDMSDatabaseApp\LDMS_Spec.xls"
strWorksheet = "WorkSheet1"
strDB = "E:\CSC\LDMS\LDMSDatabaseApp\LDMS_IFF_APP.mdb"
strTable = "Test"
Set objDB = OpenDatabase(strDB)
'If excel file already exists, you can delete it here
If Dir(strExcelFile) <> "" Then Kill strExcelFile
objDB.Execute _
"SELECT * INTO [Excel 8.0;DATABASE=" & strExcelFile & _
"].[" & strWorksheet & "] FROM " & "[" & strTable & "]"
objDB.Close
Set objDB = Nothing
I hope this helps.
Regards
Simon
Tue 23 Jun 2009: Automatically marked as resolved.
|
