RufussMcGee
Technical User
Private Sub cmdExport_Click()
Dim excelobj As New Excel.Application
excelobj.Visible = True
With excelobj
'Add a workbook.
.Workbooks.Add
ChDir "C:\LCD\Programming"
.Workbooks.Open FileName:="C:\LCD\Programming\PROJECT.XLS"
.Cells(1, 2).Value = Me!cboName
.Cells(2, 2).Value = Me!TxtAddress
.Cells(3, 2).Value = Me!TxtCity
.Cells(6, 2).Value = Me!TxtPhone
.Cells(7, 2).Value = Me!TxtFax
.Cells(2, 7).Value = Me!txtPM
MsgBox "Switch to Excel in the taskbar, check and save results."
'.ActiveWorkbook.Close SaveChanges:=False
.Quit
End With
Set excelobj = Nothing
End Sub
I had this code running once in another access file when I copy it this line
>>>Dim excelobj As New Excel.Application<<<
returns the following error.
>>>Compile error: User-defined type not defined<<<
What am I missing? Or should it be written different?
Thanks
Dim excelobj As New Excel.Application
excelobj.Visible = True
With excelobj
'Add a workbook.
.Workbooks.Add
ChDir "C:\LCD\Programming"
.Workbooks.Open FileName:="C:\LCD\Programming\PROJECT.XLS"
.Cells(1, 2).Value = Me!cboName
.Cells(2, 2).Value = Me!TxtAddress
.Cells(3, 2).Value = Me!TxtCity
.Cells(6, 2).Value = Me!TxtPhone
.Cells(7, 2).Value = Me!TxtFax
.Cells(2, 7).Value = Me!txtPM
MsgBox "Switch to Excel in the taskbar, check and save results."
'.ActiveWorkbook.Close SaveChanges:=False
.Quit
End With
Set excelobj = Nothing
End Sub
I had this code running once in another access file when I copy it this line
>>>Dim excelobj As New Excel.Application<<<
returns the following error.
>>>Compile error: User-defined type not defined<<<
What am I missing? Or should it be written different?
Thanks