How to add and remove spredsheets

Y

yosi_lb

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

thanks
 
C

Chip Pearson

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)
 
Y

yosi_lb

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)
 
Top