How to add and remove spredsheets

  • Thread starter Thread starter yosi_lb
  • Start date Start date
Y

yosi_lb

hi all
I need help
how do i add or remove spredsheets from excel workbook with visualbasic 6.

thanks
 
Assuming you have an object variable set to the Excel Application (using
GetObject or CreateObject), you can do something like

XL.ActiveWorkbook.Worksheets("Sheet1").Delete
or
XL.ActiveWorkbook.Worksheet.Add

where XL is an object variable referring to the Excel Application. E.g.,

Public XL As Excel.Application
On Error Resume Next
Set XL = GetObject(,"Excel.Application") ' note leading comma
If XL Is Nothing Then
Set XL = CreateObject ("Excel.Application")
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
thanks
it realy help

Chip Pearson said:
Assuming you have an object variable set to the Excel Application (using
GetObject or CreateObject), you can do something like

XL.ActiveWorkbook.Worksheets("Sheet1").Delete
or
XL.ActiveWorkbook.Worksheet.Add

where XL is an object variable referring to the Excel Application. E.g.,

Public XL As Excel.Application
On Error Resume Next
Set XL = GetObject(,"Excel.Application") ' note leading comma
If XL Is Nothing Then
Set XL = CreateObject ("Excel.Application")
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top