|
-
Aug 8th, 2002, 10:54 AM
#1
Thread Starter
Lively Member
Export a MS acess table to excel throug VB
I have some data in msacess table which i have to export to a excel file from VB 6
Can I do that
Their is be excel in the user pc but thy dont have MS acess
Can u help me to expot a Table
It might be a recordset which has be created by Select Statement
with Regards
sameer Mulgaonkar

-
Aug 8th, 2002, 11:36 AM
#2
PowerPoster
you can do it on a pc that has excel and access. are you saying that you want to do the export once so that the users can get at the data through excel or are you saying that you want to be able to do the export frequently from a machine that does not have access?
you could do the export on the machine that has both and then send everyone the excel file
-
Aug 9th, 2002, 07:24 AM
#3
Try this...
VB Code:
Private Sub ExportOneTable()
'EXPORTS TABLE IN ACCESS DATABASE TO EXCEL
Dim strExcelFile As String
Dim strWorksheet As String
Dim strDB As String
Dim strTable As String
Dim objDB As Database
'Change Based on your needs, or use
'as parameters to the sub
strExcelFile = "C:\My Documents\MySpreadSheet.xls"
strWorksheet = "WorkSheet1"
strDB = "C:\My Documents\MyDatabase.mdb"
strTable = "MyTable"
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
End Sub
-
Aug 9th, 2002, 08:43 AM
#4
Hyperactive Member
If you have Access why don't you just use..
VB Code:
DoCmd.OutputTo acOutputTable, "Your Table", acFormatXLS, "File Name", True
in an Access function?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|