Need some assistance with my code below. All I am trying to do is export data from a table into excel. I receive a type mismatch error that I can't figure out on this line of code.
Any ideas?
Thanks,
GJ
Any ideas?
Thanks,
GJ
Code:
Set rs = db.OpenRecordset(strSh, dbOpenSnapshot)
Code:
Function Export()
Dim xlobj As Object
Dim objWKB As Object, objSHT As Object
Dim rs As Recordset
Dim db As Database
Dim strSh As String
Const conSHEET1 = "SHARES"
Const conBK = "C:\Documents and Settings\Workstation\Desktop\Shares.xls"
Set xlobj = CreateObject("excel.application")
Set db = CurrentDb
xlobj.Application.Visible = True
With xlobj
.workbooks.Open filename:=conBK
strSh = ("SELECT D1NAME, MEMBER_NBR FROM tblShares")
Set rs = db.OpenRecordset(strSh, dbOpenSnapshot)
Set objSHT = .worksheets(conSHEET1)
With objSHT
.rnge("A1:H65000").copyRecordset rs
End With
.activeworkbook.Close savechanges:=True
xlobj.Quit
End With
Set xlobj = Nothing
End Function