+ Reply to Thread
Results 1 to 5 of 5

Disabling a Macro in the workbook

Hybrid View

Hlowmaster Disabling a Macro in the... 06-30-2010, 09:35 PM
mikerickson Re: Disabling a Macro in the... 06-30-2010, 09:51 PM
Hlowmaster Re: Disabling a Macro in the... 06-30-2010, 10:52 PM
royUK Re: Disabling a Macro in the... 07-01-2010, 01:01 AM
Hlowmaster Re: Disabling a Macro in the... 07-01-2010, 09:34 AM
  1. #1
    Registered User
    Join Date
    06-15-2010
    Location
    Kansas
    MS-Off Ver
    Excel 2003
    Posts
    60

    Disabling a Macro in the workbook

    Is htere a way to make an if then statement liike


    If this macro is activated from a button then disable this private sub in the workbook module? then when the macro is done it re enables it

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Disabling a Macro in the workbook

    You can use Application.Caller to determine if a routine has been called as the result of a button click.

    It would be easier to use that to branch around calling the sub rather than disabling the sub.

    If TypeName(Application.Caller) <> "String" Then
        Call theMacro
    End If
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    06-15-2010
    Location
    Kansas
    MS-Off Ver
    Excel 2003
    Posts
    60

    Re: Disabling a Macro in the workbook

    That work excepts the code in the workbook is to disable the save function.. And the macro i'm calling is to save something.. see its like.. you can't go to file menu save and save as.. only if you click the save "button" in the sheet.. if that makes sense.. then the macro saves it to a certain location.. not where somebody wants to save it

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Disabling a Macro in the workbook

    Are you using the before save event?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    06-15-2010
    Location
    Kansas
    MS-Off Ver
    Excel 2003
    Posts
    60

    Re: Disabling a Macro in the workbook

    Yes I Am.. its like

    
    
    
    Private Sub Workbook_BeforeSave(ByVal SaveUI As Boolean, Cancel As Boolean)
        
        If Sheets("Sheet1").Select & Range("A5").Value > 0 Then
        
            ActiveWorkbook.SaveAs Filename:="C:\Users\Hunter\Documents\" & Range("A1").Value, _
                              FileFormat:=xlOpenXMLWorkbookMacroEnabled, _
                              CreateBackup:=False
        
        ElseIf Sheets("Sheet1").Select & Range("A5").Value = 0 Then
    
        Cancel = True
        MsgBox "Uh uh"
        
        End If
          
    End Sub
    except that crashes the workbook i need something like that though where save and save as is disabled.. but u can push a button and it will save to a certain directory

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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