KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Remove worksheets in excel

 
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic
View previous topic :: View next topic  
Author Message
mima500
KiXforms Regular
KiXforms Regular


Joined: 11 Dec 2003
Posts: 48
Location: Sweden

PostPosted: Thu Oct 26, 2006 8:28 am    Post subject: Remove worksheets in excel Reply with quote

Hi

Kixtart.org is closed due to database corruption, so I try with my question here instead.

I want to remove worksheet with kix but the worksheet doesnt removes.

Code:

$OutFile = "C:\Test.xls"
Del $OutFile

$objExcel = CreateObject("Excel.Application")
$objExcel.Visible = 1
$objWorkbook = $objExcel.Workbooks.Add()
      
; Remove worksheet
$objWorkbook.Worksheets.RemoveAt(2)
      
$objWorkbook.SaveAs($OutFile)
$objExcel.Quit


I have been looking on this http://www.aspose.com/wiki/default.aspx/Aspose.Cells/ManagingWorksheets.html
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Thu Oct 26, 2006 6:13 pm    Post subject: Reply with quote

hmm...
I just did a script that had delete in it. just can't remember the exact line.
iirc, it was something like:
$wb.sheets(1).remove

or .delete or...

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Thu Oct 26, 2006 6:16 pm    Post subject: Reply with quote

yep, it was delete.

so:
$workbook.sheets(2).delete

ref: http://msdn2.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet.delete.aspx

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
mima500
KiXforms Regular
KiXforms Regular


Joined: 11 Dec 2003
Posts: 48
Location: Sweden

PostPosted: Thu Oct 26, 2006 8:36 pm    Post subject: Reply with quote

Thanks Lonkero

Works perfect
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group