473,320 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Try to delete a worksheet in Excel

Hi Proggies,

i try to delete an excel worksheet but nothing happens (work on vb.net 2005)

.....
xlSheet = xlApp.Sheets("Master")
xlSheet.select
xlSheet.delete

also try

objWkb.Worksheets(sWksName).Delete

Where is the mistake ?

thx and nice weekend

Rene
Sep 8 '06 #1
3 15254
If you use excel vba, the code will be work.
If you using vb.net to build an Excel File you can´t delete a worksheet in
Excel with this typ of code.
vb.Net runs over the delete statement an nothing happens.

Sorry if my question is incomprehensibly

Rene

"Scott M." <s-***@nospam.nospamschrieb im Newsbeitrag
news:OR**************@TK2MSFTNGP05.phx.gbl...
And what was your VB.NET question?
"Rene" <re************************@gmx.dewrote in message
news:Og*************@TK2MSFTNGP06.phx.gbl...
>Hi Proggies,

i try to delete an excel worksheet but nothing happens (work on vb.net
2005)

....
xlSheet = xlApp.Sheets("Master")
xlSheet.select
xlSheet.delete

also try

objWkb.Worksheets(sWksName).Delete

Where is the mistake ?

thx and nice weekend

Rene



Sep 9 '06 #2
Let's see your entire code.
"Rene" <re************************@gmx.dewrote in message
news:uJ****************@TK2MSFTNGP04.phx.gbl...
If you use excel vba, the code will be work.
If you using vb.net to build an Excel File you can´t delete a worksheet in
Excel with this typ of code.
vb.Net runs over the delete statement an nothing happens.

Sorry if my question is incomprehensibly

Rene

"Scott M." <s-***@nospam.nospamschrieb im Newsbeitrag
news:OR**************@TK2MSFTNGP05.phx.gbl...
>And what was your VB.NET question?
"Rene" <re************************@gmx.dewrote in message
news:Og*************@TK2MSFTNGP06.phx.gbl...
>>Hi Proggies,

i try to delete an excel worksheet but nothing happens (work on vb.net
2005)

....
xlSheet = xlApp.Sheets("Master")
xlSheet.select
xlSheet.delete

also try

objWkb.Worksheets(sWksName).Delete

Where is the mistake ?

thx and nice weekend

Rene




Sep 9 '06 #3
Hello Scott,
here is my code:

Dim Vorlagenverzeichnis As String = "...."
Dim aktWorkbook As String
Dim xlApp As New Excel.Application
Dim xlSheet As Excel.Worksheet
xlApp.Workbooks.Add(Template:=Vorlagenverzeichnis)
aktWorkbook = xlApp.ActiveWorkbook.Name
xlApp.Workbooks(aktWorkbook).Sheets("Master").Copy (After:=xlApp.Sheets(xlApp.ActiveWorkbook.Sheets.C ount))
xlApp.ActiveSheet.Name = "New Create"

xlSheet = xlApp.Workbooks(aktWorkbook).ActiveSheet
xlSheet.Delete()
xlApp.Application.Visible = True

This does not work, i add a reference to Excel 10 Com Object (vb.net 1.0 and
2.0)

I try a little bit last weekend and this one will work
May late binding is a better one to use

Dim Excel As Object
Excel = CreateObject("Excel.application")
With Excel
.SheetsInNewWorkbook = 4
.Workbooks.Add()
.Worksheets(1).Select()
.worksheets(1).Name = "Test"
.worksheets("Test").delete()
.activeWorkbook.close()
End With
Excel.Quit()
Excel = Nothing
GC.Collect()

Regards Rene
"Scott M." <s-***@nospam.nospamschrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP04.phx.gbl...
Let's see your entire code.
"Rene" <re************************@gmx.dewrote in message
news:uJ****************@TK2MSFTNGP04.phx.gbl...
>If you use excel vba, the code will be work.
If you using vb.net to build an Excel File you can´t delete a worksheet
in Excel with this typ of code.
vb.Net runs over the delete statement an nothing happens.

Sorry if my question is incomprehensibly

Rene

"Scott M." <s-***@nospam.nospamschrieb im Newsbeitrag
news:OR**************@TK2MSFTNGP05.phx.gbl...
>>And what was your VB.NET question?
"Rene" <re************************@gmx.dewrote in message
news:Og*************@TK2MSFTNGP06.phx.gbl...
Hi Proggies,

i try to delete an excel worksheet but nothing happens (work on vb.net
2005)

....
xlSheet = xlApp.Sheets("Master")
xlSheet.select
xlSheet.delete

also try

objWkb.Worksheets(sWksName).Delete

Where is the mistake ?

thx and nice weekend

Rene




Sep 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mail2atulmehta | last post by:
Hi, I do not know if this is right place for this, but i need some help. I have a text file, whose values are seprated by a delimiter. I want to open this file in excel, ( not import it) . I have...
1
by: GG | last post by:
Have this code but does not delete right columns. When I ran the folllowing code only columns 14, and 15 is deleted.Col 12 and 13 are still there. Any ideas? Thanks for (int colDel = 12;...
1
by: javzxp | last post by:
Hi I'd like to use C# to open an existing Excel workbook and save each worksheet it contains into a new Excel file. The name of each new Excel file should be the name of the worksheet copied...
1
by: Rene | last post by:
Hi Proggies, i try to delete an excel worksheet but nothing happens (work on vb.net 2005) ..... xlSheet = xlApp.Sheets("Master") xlSheet.select xlSheet.delete also try
0
by: milkyman | last post by:
Hi everyone, Hope you can help me with this. I want to know if there is a way to copy a part of an Excel worksheet en put this as an picture in a picturebox. So if have got a Excel sheet(called...
3
by: sun919 via DotNetMonster.com | last post by:
hi , i have a question to ask regarding deleting the worksheet basically i have written code which find the select worksheet which work fine but it didn't delete the worksheet from the workbook...
1
by: rshivaraman | last post by:
Hi : 1. I import data into sqlserver, from an excel file, from a worksheet within it, named 'input_data' 2. then i scrub the data in sqlserver 3. then i export some data into the same excelfile...
0
by: aamirmay | last post by:
Hi, I want to delete a worksheet using VB.NET, but fail to do that. Im using the following code: XLApp = CreateObject("Excel.Application") XLWorkbook =...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.