•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 456,507 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,661 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 2533 | Replies: 3 | Solved
![]() |
•
•
Join Date: Sep 2007
Location: Atlanta, Georgia, USA
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I have created and populated an Excel workbook with 3 worksheets. Sheet1 contains data; Sheet2 and Sheet3 are empty. I massage the data in Sheet1 and enter the output into Sheet2. I would now like to delete Sheet1 and close and save the Excel file.
I am embarressed to say I can't figure out how to delete a worksheet from an Excel spreadsheet in VB6. Hope you can help me out!
I am embarressed to say I can't figure out how to delete a worksheet from an Excel spreadsheet in VB6. Hope you can help me out!
•
•
Join Date: Dec 2006
Location: United States
Posts: 613
Reputation:
Rep Power: 3
Solved Threads: 15
Try this:
Sub DeleteSheets()
dim xl as new excel.application
dim wb as excel.workbook
set wb=xl.workbooks.open("c:\test.xls"
xl.application.displayalerts=false
If wb.worksheets.count > 1
wb.worksheets(1).delete
End If
xl.application.displayalerts=true
wb.save
wb.close
xl.quit
set wb=nothing
set xl=nothing
End Sub
Sub DeleteSheets()
dim xl as new excel.application
dim wb as excel.workbook
set wb=xl.workbooks.open("c:\test.xls"
xl.application.displayalerts=false
If wb.worksheets.count > 1
wb.worksheets(1).delete
End If
xl.application.displayalerts=true
wb.save
wb.close
xl.quit
set wb=nothing
set xl=nothing
End Sub
•
•
Join Date: Sep 2007
Location: Atlanta, Georgia, USA
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
Join Date: Dec 2006
Location: United States
Posts: 613
Reputation:
Rep Power: 3
Solved Threads: 15
No Problem. Anytime. You can contribute on my site too. here
![]() |
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- opening excel file in visual basic 6 (Visual Basic 4 / 5 / 6)
- How to access and modify values of a OLE object(Excel Worksheet) (Visual Basic 4 / 5 / 6)
- How do I open existing excel document using vb6? (Visual Basic 4 / 5 / 6)
- How to continue to next new excel worksheet (ASP)
- Excel solver using VB6 (Visual Basic 4 / 5 / 6)
- Opening and manipulating a file in excel usung VB6 (Visual Basic 4 / 5 / 6)
- Problems with VB6 and excel (Visual Basic 4 / 5 / 6)
- How to write files to an Excel application (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: numeric value into words vb6
- Next Thread: Text To Grafics


Linear Mode