Free Microsoft Excel 2013 Quick Reference

cannot run the macro may not be available in this workbook

After creating and assigning macro buttons i keep getting cannot run the macro may not be available in this workbook or all macros may be disabled.


I have an excel based project. I have a GUI which I use to load, save etc. I have added buttons to the worksheet
Private Sub HomeSheet(ByVal Pattern As Excel.Worksheet)
 Dim HomeButton, NextButton, PreviousButton As Object

        PreviousButton = Pattern.Buttons.Add(0, 50, 100, 50)
        HomeButton = Pattern.Buttons.Add(150, 50, 100, 50)
        NextButton = Pattern.Buttons.Add(300, 50, 100, 50)
        HomeButton.Caption = "Home"
        PreviousButton.Caption = "Previous"
        NextButton.Caption = "Next"

        HomeButton.Enabled = True
        PreviousButton.Enabled = True
        NextButton.Enabled = True

        HomeButton.Locked = False
        PreviousButton.locked = False
        NextButton.locked = False
        '
        HomeButton.OnAction = "SelectHomeSheet"
        PreviousButton.OnAction = "SelectPreviousSheet"
        NextButton.OnAction = "SelectNextSheet"
I have a module in my project titled macros which houses the public functions SelectHomeSheet, SelectHomeSheet and SelectNextSheet. However when I run my code, the buttons generate but when I click on them I can an error
Cannot run macro ".....". This macro may not be available in this workbook or macros are disabled.
What Do I have to do to correct this?
Cheers in advance

I am getting the following error in Microsft Excel 2007 / Windows 7 when attempting to use an add-in I have installed. It used to work in Excel 2003, but does not any longer:

"Cannot run the macro "C:Douments and SettingsEnduserApplication DataMicrosoftAddInsEATickmarks.xla'!FormatRedL'. The macro may not be available in this workbook or all macros may be disabled."

I have attached a screenshot - it looks like the path of where addins were stored previously does not match up correctly. How do I manually change the path that an item in the add-in "calls" when I click on it from the ribbon?

Thanks,
Chris

I saved a macro in my personal.xlsb workbook. The macro works fine when I run it in the personal workbook, but when I try to run it for other workbooks (i.e. book1) I get the following message:

"Cannot run the macro 'Macro1'. The macro may not be available in this workbook or all macros may be disabled."

I'm running Office 2007 and I do have macros enabled in both workbooks (I can run other macros in book1).

Any help you can offer in this is appreciated.

Thank You!

I opened up an Excel 2003 workbook using Excel 2007.

After clicking on a macro the following message appeared ... Cannot run the macro “vbapractice.xls!’accessLEAPdataworksheet!. The macro may not be available in this workbook or the macro might be disabled. ... .

How do you enable the macros in Excel 2007 so they will engage?

Thanks for your time and help,
Tom

Hey guys,

I'm new VBA but not to programming...yet every once in a while, I find an eror that just throws me.

I have worked through a project I'm doing for a comapny that was written by someone else and I had most of it working, but after running a short while it would throw an error -- "Cannot run macro 'OnLoad'. The macro may not be available in this workbook or all macros may be disabled."

I have macros enabled. I have looked through as much code as I can so far and have not ONCE found a macro named "OnLoad".

Google has no answer. Yahoo has no answer. MS Support has no answer (not surprising....).

Hopefully you can help me...

Thanks for anything!

Hello all!

I've created a VBA script for Timer to call the function itself repeatedly, but I'm having some issues regarding the macro setting. I already have checked the macro security (Trust Center Setting). I enabled all options and then I saved the sheet. Reopened it and ran the script, but getting the same error.

I am using Excel 2007

Here is the message:

"Cannot run the macro "C:test.xlsm!TimerA". The macro may not be available in this workbook or all macros may be disabled."

Here is the code in Sheet1


	VB:
	
 TimerA() 
    Application.OnTime Now + TimeValue("00:00:30"), "TimerA" 
End Sub 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
I hope you can solve this problem for me

Thanks
Bryan

I have a shared workbook with information for 2 different floors in our facility. One floor will start one macro (5th) and the other floor will start macro (6th). The 5th works great but I get this error with the 6th

Cannot run the macro (then its name). The macro may not be available in this workbook or all macros may be disabled?

Any ideas on what I am doing wrong?

Hi all,
Can anyone tell me why this macro won't work:

Sub Instructor()

Application.Run
"'Macros.xlsm'!Pt4"
Application.Run "'Macros.xlsm'!Pt5"
Application.Run "'Macros.xlsm'!Pt6"
Application.Run "'Macros.xlsm'!Pt7"
Application.Run "'Macros.xlsm'!Pt8"
End Sub
The macro actually keeps going up until Pt19.

I get the error:

Run-time error '1004':
Cannot run the macro "Macros.xlsm'!pt4'. The macro may not be available in this workbook or all macros may be disabled.

However, I'm sure macros are enabled and each of the the individual macros (Pt1, Pt2...) run in the workbook individually

Any help greatly appreciated

[Solved]
I am using the function: Application.OnTime TimeValue to run a specific macro every day at 4:00 PM, but at 4:00 PM the macro tries to launch another macro but is disabled by Excel even though the macro security is set to allow it to run. If I run the “Sample_Macro_Name” manually, it runs just fine. However, as soon as I use the another macro to launch the “Sample_Macro_Name” at a specific time, when the that time occurs, instead it returns the error message:

"Cannot run the macro Sample_Macro_Name() The macro may not be available in this workbook or all macros may be disabled”

Excel version: Office 2010
Macro security: set to enable all macros to be run.
Workbook is saved as a macro enabled workbook in a “trusted file location” on my local drive.

I have tried placing the 2nd bit of code, the macro, in standard modules, worksheet modules, and ThisWorkbook module, but in every case the macro will not fire with the Application.OnTime function, but will always fire when I manually launch it. It is as if Microsoft does not allow timed macros to fire off at a certain time due to security, yet it can be manually launched.

1. Code in the ThisWorkbook module:


Private Sub Workbook_Open()
  'Runs a macro at 4:00 PM
   Application.OnTime TimeValue("16:00:00"), "Sample_Macro_Name()”
End Sub


2. Then in a regular module the code:


Sub Sample_Macro_Name()
  [Macro code goes here]
End Sub
Folks, I appreciate your wise guidance.

Hopefully someone can help me with this issue, as I am now completely lost ...

I'll try and explain it in simple terms..

I have 3 workbooks:
Workbook A
Workbook B
Workbook C

These each have one macro:
Workbook A - Macro 1
Workbook B - Macro 2
Workbook C - Macro 3

I can run Macro 1 from A, obviously, I can run it from B, but not from C.
I can run Macro 2 from B, again obviously, and I can run it from A, but not C.
I can run Macro 3 from C, but I can't run any of the others from C.

For some reason, whenever I try to run Macro 3 from either A or B, I get the error message:
Run-time error '1004': Cannot run macro . The macro may not be available in this workbook or all macros may be disabled.

The same error message appears if I try to run macro 1 or 2 from C.

My code is exactly the same in all workbooks so I know it's not the code. I have enabled all macros so I know that the disabled part isn't true.

Has anyone else ever came across this? Is there a tick box I have missed somewhere that does not let macros be run from another workbook?
I am totally lost with this as I see no difference in workbook C that I do with any of the other two.

Any help or input would be greatly appreciated.

This is the only site I have posted on, but I have asked our IT team if they have ever came accross this and no-one had. I also checked the microsoft website for any help and found nothing on there that was related.

Thanks in advance

Hi-

I have put the following simple code into a new module in my worksheet:

Public RunWhen As
Double
Public cRunIntervalSeconds As Double
Public Sub StartTimer()
    cRunIntervalSeconds = Worksheets("Signals").Range("Interval").value
    RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
    Application.OnTime EarliestTime:=RunWhen, Procedure:="Toggle", Schedule:=True
End Sub
Public Sub StopTimer()
    On Error Resume Next
    Application.OnTime EarliestTime:=RunWhen, Procedure:="Toggle", Schedule:=False
End Sub
Public Sub Toggle()
    Worksheets("Signals").Range("Toggle") = "TRUE"
    'Reschedule next run
    Call StartTimer
End Sub
It seems to schedule okay, but when 60 seconds is up (the interval value in Worksheets("Signals").Range("Interval").value) it gives the following error message:

"Cannot run the macro "...Toggle". The macro may not be available in this workbook or all macros may be disabled". However, i do have my trust center settings to enable all macros. Does anyone have any ideas what is going on? I'm stumped. Thanks.

Hi Guys,

The following code has been provided on a prior thread to add macro option to 2003 but I cant get it to function fully in 2007 as I get the following message when the 'run my code' option is selected from the right click menu;

Cannot run macro "macro test 4.xlsm'!mymacroname'. The macro may not be available in this workbook or all macros may be disabled.

Thank you for any assistance... Kabes
Sub AddToCellMenus()

   Dim cbr As CommandBar, ctl As CommandBarButton
   For Each cbr In Application.CommandBars
      If cbr.Name = "Cell" Then
         Set ctl = cbr.Controls.Add(msoControlButton)
         With ctl
            .Caption = "run my code"
            .OnAction = "mymacroname"
            .Style = msoButtonCaption
         End With
      End If
   Next cbr
End Sub

Sub RemoveFromCellMenus()
   Dim cbr As CommandBar
   On Error Resume Next
   For Each cbr In Application.CommandBars
      If cbr.Name = "Cell" Then
         cbr.Controls("run my code").Delete
      End If
   Next cbr
End Sub

Sub mymacroname()

    MsgBox "help me..."

End Sub


I'm trying to call a sub in an exce. file that resides on our network drive so that multiple users can access the programs that I develop and I can get VBA to open the file but I can't get it to open the sub titled "DCU". I keep getting the following error.
Cannot run the macro DCU. The macro may not be available in this workbook or all macros may be disabled. Here is my code that errors.
Code:
Option Explicit
Sub DESCRIPTION_CLEANER_UPPER()
Application.Visible = True
Workbooks.Open Filename:= _
        "Cansvp01grp_01fCommonCommon-PartsPrcngMacrosMacros.xls"
Application.Run "DCU"
End Sub
Any help is greatly appreciated, maybe I'm calling it wrong or maybe there's another way to accomplish what I'm trying to do here.

Code:
sub nextorders()
MsgBox "works!"
end sub

sub startTimer()
Application.OnTime Now, "nextorders"
end sub
This doesn't work for me!!
CANNOT RUN THE MACRO "D:BOOK1.XLSM'!NEXTORDERS'. THE MACRO MAY NOT BE AVAILABLE IN THIS WORKBOOK OR ALL MACROS MAY BE DISABLED.

wth?? All macros are enabled on Excel 2007, what's the problem??
thank you

Hello Experts,

I have a macro with "ActiveWorkbook.Protect Password:="password"" . It was working fine in excel 2003. In excel 2007, because of this I am not able to run any macro's in the workbook. I am getting a message "The macro may not be available in this workbook or all macros may be disabled. I can see a security warning in message bar saying macros have been disabled, but I dont have have a option to enable the macros.

Any help is greatly appriciated.

Lavan

Hello,

I was using Excel Premium Solver with XP without problems. When we moved to
the Vista platform, I re-installed the solver, but every time I try to run
the solver add-in, I get the message "Cannot run the macro Solver.xla!stub".
The macro may not be available in this workbook or all macros may be
disabled." I explicitly enabled ,acros, and I can run other add-ins, so I'm
pretty sure that is not the problem. We have noe changed the version of Excel
that we're using, but I still tried VB converters, but that didn't do it,
either. Any help would be appreciated.

I have the following code in ThisWorkbook module. There is no other code in the workbook and it is a new blank workbook with no data.

I open the file and give permission for macros to run, leave the file open, and then do other work in other applications. After the expected time period has elapsed I check a Windows Explorer window and see that the file date has not changed. I get the following error when I return focus to Excel. I get this error message in a modal dialog box. What could cause this:
Cannot run the macro "C:Document and SettingsAdministratorMy DocumentsExcel ExamplesSave Periodically.xlsm'!SaveMe'. The macro may not be available in this workbook or all macros may be disabled.
I am able to run the macro by hitting F5 in the VBA environment so I confirmed that macros will run.

Option
Explicit
Dim TimeInterval As Variant
Public Sub Workbook_Open()
   Debug.Print "Opening " & Now
   TimeInterval = TimeValue("00:05:00")
   Application.OnTime earliesttime:=Now + TimeInterval, procedure:="SaveMe"
End Sub
Public Sub SaveMe()
   Debug.Print "Saving " & Now
   ThisWorkbook.Save
   Application.OnTime earliesttime:=Now + TimeInterval, procedure:="SaveMe"
End Sub


I have a very large pivot table and when I refresh the data I get the following message
<cannot run the macro 'Morefunc.OnRecalc'. The macro may not be available in this workbook or all macros may be disabled.>

The pivot still seems to be updating, but how can I resolve this error message?

thanks

Hi I've done up a workbook with 2 combo box, one's range dependent on the first. After playing around with cos codings and fomular with help of others in this forum, I'm able to get the dependent combo box to display the range i want but i'm unable to offset the empty cells, and for the dependent range. It also gives the following error when i select any value in the second combo box. Cannot run the macro "Test work.xlsx'!BU'. The macro may not be available in this workbook or macros may be disabled. Can anyone help me out on this?

On a side note, can i retrieve the actual selected value of a combo box into a designated cell?

Thank you

I have the following code:

Option Explicit

Sub Consolidate()
    Dim MyPath As String
    Dim FilesInPath As String
    Dim MyFiles() As String
    Dim Fnum As Long
    Dim mybook As Workbook
    Dim CalcMode As Long
    Dim sh As Worksheet
    Dim ErrorYes As Boolean
    Dim DCLastRow As Integer 'DirectorCopy
    Dim MCLastRow As Integer 'Monthly Compiler
    Dim CMonth As String 'Compile Month
    Dim CYear As String 'Compile Year
    Dim Month As Integer
    Dim MonthFilter As String

    Dim center(18) As String
    center(1) = "Bardstown"
    center(2) = "Bothell"
    center(3) = "VCollinsville"
    center(4) = "El Paso"
    center(5) = "Evansville"
    center(6) = "Greensboro"
    center(7) = "VHeathrow"
    center(8) = "Joplin"
    center(9) = "Kennesaw"
    center(10) = "Lafayette"
    center(11) = "Malvern"
    center(12) = "VManhattan"
    center(13) = "VMansfield"
    center(14) = "VOttawa"
    center(15) = "VPonco City"
    center(16) = "VReno"
    center(17) = "VSioux City"
    center(18) = "VTerra Haute"
    
    Dim FileCount As Long
    Dim ScoringAve As Double
    Dim i As Long
    
'    If Cells(13, 4).Value = "January" Then Month = 1
'    If Cells(13, 4).Value = "February" Then Month = 2
'    If Cells(13, 4).Value = "March" Then Month = 3
'    If Cells(13, 4).Value = "April" Then Month = 4
'    If Cells(13, 4).Value = "May" Then Month = 5
'    If Cells(13, 4).Value = "June" Then Month = 6
'    If Cells(13, 4).Value = "July" Then Month = 7
'    If Cells(13, 4).Value = "August" Then Month = 8
'    If Cells(13, 4).Value = "September" Then Month = 9
'    If Cells(13, 4).Value = "October" Then Month = 10
'    If Cells(13, 4).Value = "November" Then Month = 11
'    If Cells(13, 4).Value = "December" Then Month = 12
'    CMonth = MonthName(Month, True)
    'This one line of code replaces the above 13 lines
    CMonth = Left(Cells(13, 4).Value, 3)
    CYear = Right(Cells(13, 7).Value, 2)

           
    'Fill in the pathfolder where the files are
    MyPath = "X:C&A Analysts TeamPF Process1 Tally & PF's Work in 
ProgressCenters"
    
    For i = 1 To 18
        
'        'Add a slash at the end if the user forget it
'        If Right(MyPath, 1) <> "" Then
'            MyPath = MyPath & ""
'        End If
        
        'If there are no Excel files in the folder exit the sub
        MonthFilter = MyPath & center(i) & "*" & CMonth & " " & CYear & 
"*.xl*"
        FilesInPath = Dir(MonthFilter)
        
        If FilesInPath = "" Then
            MsgBox "No files found in " & center(i)
            GoTo ContinueLoop
        End If
        
        If FilesInPath <> "" Then
            FileCount = FileCount + 1
        End If
        
        'Fill the array(myFiles)with the list of Excel files in the folder
        Fnum = 0
        Do While FilesInPath <> ""
            If InStr(1, FilesInPath, CMonth & " " & CYear, vbTextCompare) Then
                Fnum = Fnum + 1
                ReDim Preserve MyFiles(1 To Fnum)
                MyFiles(Fnum) = FilesInPath
                FilesInPath = Dir()
            End If
        Loop
    
        'Change ScreenUpdating, Calculation and EnableEvents
        With Application
            CalcMode = .Calculation
            .Calculation = xlCalculationManual
            .ScreenUpdating = False
            .EnableEvents = False
        End With
    
        'Loop through all files in the array(myFiles)
        If Fnum > 0 Then
            For Fnum = LBound(MyFiles) To UBound(MyFiles)
                Set mybook = Nothing
                On Error Resume Next
                Set mybook = Workbooks.Open(MyPath & center(i) & "" & 
MyFiles(Fnum))
                On Error GoTo 0
    
                If Not mybook Is Nothing Then
    
                    'Need to do the following:
                    'if lazy eye hasn't been run in directorcopy then run it
                    With mybook.Worksheets("DirectorCopy")
                        If .Cells(1, 1) = "" Then
                            Application.Run "DirectorFormat"
With Application.Run I'm getting the following error:

Cannot run the macro 'DirectorFormat'. The macro may not be available in
this workbook or all macros may disabled.

Here is the code for DirectorFormat:

Sub
DirectorFormat()

    Dim TSLastPFRow As Integer   'Tally Sheet
    Dim TSPFTotal As Integer     'Tally Sheet PF
    Dim ZeroRow As Long, i As Long
   
    With Sheets("Tally Sheet")
        .Cells.Copy
        .Paste Destination:=Worksheets("DirectorCopy").Range("A1")
    End With
    
    With Worksheets("DirectorCopy")
        '.Shapes("LazyEyeButton").Cut
        For j = 1 To 64
            .Shapes("Done! " & j).Cut
        Next
        
        .Columns("G:G").Delete
        .Cells.Copy
        .Cells.PasteSpecial Paste:=xlPasteValues, 
Operation:=xlPasteSpecialOperationNone, _
        SkipBlanks:=False, Transpose:=False
        
        'Find the last PF
        For i = 4 To Rows.Count Step 8
            If Cells(i, "A").Value = 0 Then
                ZeroRow = i
                Exit For
            End If
        Next

        TSLastPFRow = ZeroRow - 9
        TSPFTotal = (Val(Replace(Cells(TSLastPFRow, 1).Value, "_PF", "")))
        
        'Delete empty PFs at the bottom
        .Range(ZeroRow & ":515").Delete
        
        'Delete all title bars except the first one
        For i = (ZeroRow - 7) To 13 Step -8
            .Rows(i).Delete
        Next
        
        .Rows("4:4").Select
        ActiveWindow.FreezePanes = True
    End With
End Sub
It's not set to private and I don't have my macros disabled. The code isn't
that long so I suppose I could just duplicate it in this macro but that seems
like "poor coding" to me if it's already somewhere else. What am I doing
wrong?

Edit: Ok, figured it out. Needed to include the path. So instead of:

I'm using:



I have one excel sheet & i m unable to work with that whenever i m going to work in Loging tab this message is coming "cannot run the macro "P6.x ACTIVITY.xls'!GetExpenses_Click'. The macro may not be available in this workbook or all macros may be diasbled."

pls help........

Hi all,
Can anyone tell me why this macro won't work:

Sub Instructor()

Application.Run "'Macros.xlsm'!Pt4"
Application.Run "'Macros.xlsm'!Pt5"
Application.Run "'Macros.xlsm'!Pt6"
Application.Run "'Macros.xlsm'!Pt7"
Application.Run "'Macros.xlsm'!Pt8"

End Sub
The macro actually keeps going up until Pt19.

I get the error:

Run-time error '1004':
Cannot run the macro "Macros.xlsm'!pt4'. The macro may not be available in this workbook or all macros may be disabled.

However, I'm sure macros are enabled and each of the the individual macros (Pt1, Pt2...) run in the workbook individually

Any help greatly appreciated

I am getting an error msg after emailing a macro enabled file:

Cannot run macro C:Documents...The macro may not be available in this workbook..

I have already saved the macro file as a macro enabled file

Edit: Sorry, wrong thread, can somebody move to programming please?

Hello,

Looking for a little help here. Basically what I need to do is assign a macro to a button I create in VBA code. Ultimately what is happening in my program is:

I need a simple way for our program assistant to generate certain data in a fixed way so she can do a mail merge later on. The data she needs is stored in a SQL database. What I want to do is pull a list of SessionID's for her in column A, in column B create a Button that she can click and when clicked with create the excel document that she can use in her mail merge.

I have the SQL code done(for both sections, just showing part 1 now), now I just need to get my button to work. So far this is what I have.

Sub btnS()
     MsgBox ("Test")
End Sub

Sub getData()
    Dim conn As Variant
    Dim rs As Variant
    Dim cs As String
    Dim query As String
    Dim row As Integer
    Dim btn As Button
    Dim t As Range
    
    Sheet1.Cells.Clear
    
    Set conn = CreateObject("adodb.connection")
    Set rs = CreateObject("adodb.recordset")
    
    'The database in this instance has been set as Northwind.
    'you will need to update the database for what yours is called.
    'The IP Address '127.0.0.1' represents localhost.  If you
    'are trying to connect to a remote sql server then you will
    'either need to enter the ip address or URL of that server.
    'In the connection string below, 1433 is the port number
    'the SQL server is listening on.  If your sql server is
    'listening on a different port you'll have to change it.
    '1433 is the default port for SQL Server.
    
    
    cs = "DRIVER=SQL Server;"
    cs = cs & "DATABASE=***;"
    cs = cs & "SERVER=***"
    
    'parameters here are connectionSring, username, password
    'you will need to put the actual username and password in
    'quotes here for this code to work.
    conn.Open cs, "***", "***"
        
    query = "SELECT SessionNumber FROM cerSession WHERE RowStatus = 'A' ORDER BY SessionNumber DESC"
    rs.Open query, conn
    
   
    row = 0
    Do Until rs.EOF
        row = row + 1
        Cells(row, 1).Value = rs.Fields("SessionNumber").Value
        Set t = ActiveSheet.Range(Cells(row, 2), Cells(row, 2))
        Set btn = ActiveSheet.Buttons.Add(t.Left, t.Top, t.Width, t.Height)
        With btn
            .Caption = "Generate"
            .Name = rs.Fields("SessionNumber").Value
            .OnAction = "btnS"
        End With
        rs.movenext
    Loop

     
    'If rs.State = adStateOpen Then
        rs.Close
    '    Set rs = Nothing
    'End If
    
    conn.Close
    Set conn = Nothing
    
    btnS

End Sub
The above code populates column A with the SessionID and column B with a button with the title 'Generate' however when I click the button I get this following error:

"Cannot run the macro 'Book2.xlsm!btnS'. The macro may not be available in this workbook or all macros may be disabled."

even though the btnS call at the end of my code works. Perhaps I am looking at this all wrong but any help would be greatly appreciated. I've spent a few hours scouring Google but nothing has helped so far.