can't delete a worksheet in another worksheet

siestetix

New Member
Joined
Jun 18, 2010
Messages
2
Hi guys,
help me with this cause i'm totally freaking out
the error is probably very stupid but i can't find it
i spent two hours looking everywhere

i simply wrote a macro that deletes (hopefully) a sheet in another workbook

here's the code:

Code:
Sub aaa()
Dim excelApp As Excel.Application
Dim sampleWbk As Workbook
Dim wshDelete As Worksheet
Dim path As String

path = "C:\Documents and Settings\Visiant\Desktop\estrazione settimanale\VF IT 07-13 Giugno 2010.xls"

Set excelApp = CreateObject("Excel.Application")
Set sampleWbk = excelApp.Workbooks.Open(path)

'Set sampleWbk = excelApp.Workbooks.Open("C:\Documents and Settings\VF IT 07-13 Giugno 2010.xls")

Set wshDelete = sampleWbk.Worksheets("Supporto")
Application.DisplayAlerts = False
wshDelete.Delete
Application.DisplayAlerts = True
sampleWbk.Save
sampleWbk.Close

End Sub
the macro doesn't return any error, everything seems fine but when i open the VF IT 07-13 Giugno 2010.xls the sheet is still there!!
ideas?
Thanx in advance!!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
SamTYler, u're a genius!!!
but ... why??
what's wrong with "excelApp."??
i always open workbook like that!!
Thanx again!
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top