koketsomaseko
Registered User.
- Local time
- Today, 04:01
- Joined
- Jun 17, 2014
- Messages
- 11
I have a Listbox named List5 and a search textbox named txtProperty and a table name sms , after i search in textbox the results in listbox . i would link to inport the results in listbox to excel but the code i have export the whole table to excel , please help:
here is my code
''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*'
''''''''*''''''''*'''''''' BUTTON 3 ''''''''*''''''''*''''''''*'''''''
''' EXPORT THE LIST TO EXCEL AS List5.XLS ''''''''*''''''''*''
''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*'
''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*'
Dim outputFileName As String
Dim oXL As Object
Dim oExcel As Object
Dim sFullPath As String
Dim sPath As String
outputFileName = CurrentProject.Path & "\List5.xls"
DoCmd.TransferSpreadsheet acExport, _
acSpreadsheetTypeExcel9, _
"sms", _
outputFileName, _
True ' HasFieldNames
MsgBox "Data has been exported to " & outputFileName
' Create a new Excel instance
Set oXL = CreateObject("Excel.Application")
' Only XL 97 supports UserControl Property
On Error Resume Next
oXL.UserControl = True
On Error GoTo 0
sFullPath = outputFileName
' Open it
With oXL
.Visible = True
.Workbooks.Open (sFullPath)
End With
here is my code
''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*'
''''''''*''''''''*'''''''' BUTTON 3 ''''''''*''''''''*''''''''*'''''''
''' EXPORT THE LIST TO EXCEL AS List5.XLS ''''''''*''''''''*''
''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*'
''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*''''''''*'
Dim outputFileName As String
Dim oXL As Object
Dim oExcel As Object
Dim sFullPath As String
Dim sPath As String
outputFileName = CurrentProject.Path & "\List5.xls"
DoCmd.TransferSpreadsheet acExport, _
acSpreadsheetTypeExcel9, _
"sms", _
outputFileName, _
True ' HasFieldNames
MsgBox "Data has been exported to " & outputFileName
' Create a new Excel instance
Set oXL = CreateObject("Excel.Application")
' Only XL 97 supports UserControl Property
On Error Resume Next
oXL.UserControl = True
On Error GoTo 0
sFullPath = outputFileName
' Open it
With oXL
.Visible = True
.Workbooks.Open (sFullPath)
End With