Results 1 to 2 of 2

Thread: [RESOLVED] Can't delete excel sheet

  1. #1

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Resolved [RESOLVED] Can't delete excel sheet

    I have the ff. code, I've tried deleting the base sheet but I can't, anyone who could pinpoint what I maybe doing wrong?

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim test    As Excel.Application
    3.     Dim wkb     As Excel.Workbook
    4.     Dim sht     As Excel.Worksheet
    5.     Dim a       As Integer
    6.    
    7.     Set test = New Excel.Application
    8.     Set wkb = test.Workbooks.Open("C:\LogisticsReport.xls")
    9.    
    10.    
    11.     'Create a 30 copy clone of the base sheet
    12.     For a = 1 To 30
    13.         wkb.Sheets(1).Copy After:=wkb.Sheets(wkb.Sheets.Count)
    14.         wkb.ActiveSheet.Name = "dee-u" & a
    15.         wkb.ActiveSheet.Range("B4").Value = "dee-u" & a
    16.     Next
    17.    
    18.     'Macro:
    19.     'Sheets("dee-u1").Select
    20.     'ActiveWindow.SelectedSheets.Delete
    21.    
    22.     Set sht = wkb.Sheets(1)
    23.     sht.Delete
    24.    
    25.     'wkb.Sheets(1).Select
    26.     'wkb.ActiveSheet.Delete
    27.     'wkb.Sheets(1).Delete
    28.     'test.Sheets(1).Delete
    29.    
    30.     test.Visible = True
    31. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  2. #2

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Can't delete excel sheet

    Got it, I had to add...

    VB Code:
    1. test.DisplayAlerts = False
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width