Hello ter,
I am using the following code to export tables to excel sheets..Well the problem is i have to define the path for my Database file, The database file will always be on the users Desktop. I need to know hw do u define desktop path for any user...THANK YOU
Private Sub Command0_Click()
'Export function
'EXPORTS TABLE IN ACCESS DATABASE TO EXCEL
'REFERENCE TO DAO IS REQUIRED
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:\Book.xls"
strWorksheet = "UAE"
strWorksheet1 = "USA"
strDB = "D:\Documents and Settings\vvasudev\Desktop\Export.mdb"
strTable = "A"
strTable1 = "B"
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.Execute _
"SELECT * INTO [Excel 8.0;DATABASE=" & strExcelFile & _
"].[" & strWorksheet1 & "] FROM " & "[" & strTable1 & "]"
objDB.Close
Set objDB = Nothing
End Sub
I am using the following code to export tables to excel sheets..Well the problem is i have to define the path for my Database file, The database file will always be on the users Desktop. I need to know hw do u define desktop path for any user...THANK YOU
Private Sub Command0_Click()
'Export function
'EXPORTS TABLE IN ACCESS DATABASE TO EXCEL
'REFERENCE TO DAO IS REQUIRED
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:\Book.xls"
strWorksheet = "UAE"
strWorksheet1 = "USA"
strDB = "D:\Documents and Settings\vvasudev\Desktop\Export.mdb"
strTable = "A"
strTable1 = "B"
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.Execute _
"SELECT * INTO [Excel 8.0;DATABASE=" & strExcelFile & _
"].[" & strWorksheet1 & "] FROM " & "[" & strTable1 & "]"
objDB.Close
Set objDB = Nothing
End Sub