469,645 Members | 1,393 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Delete Excel worksheet

5
Hello all,

I am trying the below code to delete a worksheet using VB.NET..I amgeeting an error with the delete...any idea where this could be wrong..

Dim str_path As String
Dim str_name As String
str_path = "C:\Biju\SSIS\Reports\0000215574.xls"
str_name = "Loss_Related"

Dim appExcel As Excel.Application
Dim wbTARGET As Excel.Workbook
Dim shts As Excel.Worksheet
Dim cnt As String

appExcel = CType(CreateObject("Excel.Application"), Excel.Application)
wbTARGET = appExcel.Workbooks.Open(str_path)


cnt = wbTARGET.Worksheets.Count.ToString()

wbTARGET.Worksheets.Select(str_name)
wbTARGET.Worksheets.Delete() ==> Error in this line..
Sep 8 '07 #1
2 1955
kenobewan
4,871 Expert 4TB
What error are you getting... something to do with permissions?
Sep 8 '07 #2
Bxitty
5
What error are you getting... something to do with permissions?


Thanks..I got the answer..it was partly to do with the way I was declaring the objects...
Sep 9 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Randall Arnold | last post: by
2 posts views Thread by Bas | last post: by
3 posts views Thread by sun919 via DotNetMonster.com | last post: by
6 posts views Thread by gumbystation | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.