Deleting Sheets in Excel XP from Access XP

Ice Rhino

Registered User.
Local time
Today, 02:29
Joined
Jun 30, 2000
Messages
210
Why does the following not delete the listed sheets in excel?

Private Sub cmdbtn_crewebbasexcgra_Click()
Dim xlSheet As Object, myfield As Variant, xlApp As Object, xlWork As Object, Strfile As String
Dim MyDb As Database, MyQuery As QueryDef, strSQL As String
Dim objXLBook As Excel.Workbook
Dim objXLSheet As Excel.Worksheet
Dim Response

Strfile = "c:\Documents and Settings\Ice Rhino\My Documents\Work Related\D2KLite\WebGraphs.xls"

Set xlApp = CreateObject("Excel.Application")
Set xlWork = xlApp.Workbooks.Open(Strfile)
Set xlSheet = xlWork.Sheets("Date_Info")
myfield = Me!txt_dateheader
xlSheet.Cells(1, 1).Value = myfield


xlWork.Worksheets(4).Delete
xlWork.Worksheets(5).Delete
xlWork.Worksheets(6).Delete
xlWork.Worksheets(7).Delete

xlWork.Save
xlApp.Quit
Set xlSheet = Nothing
Set xlApp = Nothing
Set xlWork = Nothing


Anybody got any ideas?

IR
 
For those of you who were dying to respond to this, please do not worry about it.

The code works great in Access & Excel 2000, it just does not work on my Access XP developer machine.

frown.gif


Toni
 

Users who are viewing this thread

Back
Top Bottom