Results 1 to 5 of 5

VBA code hanging in Excel after file delete

Threaded View

  1. #1
    Registered User
    Join Date
    09-02-2014
    Location
    Romania
    MS-Off Ver
    2007
    Posts
    12

    VBA code hanging in Excel after file delete

    Hi,
    I tested a code in a file that disabled sheet delete and rename.
    Now in every Excel file I create or open I can't rename any sheet, if I try Excel tries to open the initial file that had the code and tries to run a module procedure.
    The code was:

    In a sheet:
    Private Sub Worksheet_Activate()
        For Each SHT_OPTIONS In Application.CommandBars
            Set SHT_DELETE = SHT_OPTIONS.FindControl(ID:=847, recursive:=True)
            Set SHT_RENAME = SHT_OPTIONS.FindControl(ID:=889, recursive:=True)
            If Not SHT_DELETE Is Nothing Then
                SHT_DELETE.OnAction = "PUB_SHEET_DISABLE"
                SHT_DELETE.State = msoButtonUp
            ElseIf Not SHT_RENAME Is Nothing Then
                SHT_RENAME.OnAction = "PUB_SHEET_DISABLE"
                SHT_RENAME.State = msoButtonUp
            End If
        Next SHT_OPTIONS
    End Sub
    
    Private Sub Worksheet_Deactivate()
        For Each SHT_OPTIONS In Application.CommandBars
            Set SHT_DELETE = SHT_OPTIONS.FindControl(ID:=847, recursive:=True)
            Set SHT_RENAME = SHT_OPTIONS.FindControl(ID:=889, recursive:=True)
            If Not SHT_DELETE Is Nothing Then
                SHT_DELETE.OnAction = ""
            ElseIf Not SHT_RENAME Is Nothing Then
                SHT_RENAME.OnAction = ""
            End If
        Next SHT_OPTIONS
    End Sub
    In a module:
    Public SHT_OPTIONS As CommandBar
    Public SHT_RENAME As CommandBarControl
    Public SHT_DELETE As CommandBarControl
    Public Sub PUB_SHEET_DISABLE()
        MsgBox "Option disabled !", vbOKOnly + vbExclamation, "Warning"
    End Sub
    Any idea how to get rid of this?
    Thank you in advance!
    Last edited by apophysz; 06-08-2015 at 02:07 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA Save Code Intermittment Hanging
    By hobbiton73 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-08-2014, 08:37 AM
  2. VBA code to delete an excel file
    By Stev in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-16-2009, 11:03 AM
  3. VB Code to delete a file
    By JahJr in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-25-2009, 10:27 PM
  4. Line of code hanging up on one machine???
    By Don G - ExcelForums.com in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-21-2005, 06:06 PM
  5. charting code hanging up
    By Papa Jonah in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-03-2005, 01:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1