2

So I have a macro that has no errors. If I go to visual basic and hit F5 or F8 it will run. If I go to the View Macros menu and choose it, it will run.

However, if I set a keyboard shortcut, place it in the quick access toolbar, or add it to the ribbon, none of those do anything.

This is MS Project 2010 Professional. Version info. System info.

Additional information: I created a new macro from scratch and it has the exact same symptom. It seems to be an issue with the program, not the macro itself.

7
  • Where is the code located? In the global.mpt, a public module, or a private module? How is the procedure declared? Is it a public or private sub? FWIW I can't get keyboard shortcuts to work on Project 2013 Pro, but the fact that it won't run from the quick access toolbar is an issue. Commented Jan 26, 2018 at 17:50
  • It's a module in Global.mpt. THe procedure is declared as a public sub (sub Macro1).
    – Greg Viers
    Commented Jan 26, 2018 at 17:54
  • Have you checked your Trust Center settings (from the Project Options box)? And just to be sure, can you put a breakpoint on the first line of code to make sure the sub is not being called when launched from the quick access toolbar? Commented Jan 26, 2018 at 18:04
  • Yes i used a breakpoint. Also I tried with debug.print "hello" as the first line. Doesn't get called. I set trust center to run all macros, still did not run.
    – Greg Viers
    Commented Jan 26, 2018 at 18:06
  • I found a few other posts with this issue, but no solution. Here are some things to try: 1) Check Disabled Items (Options: Add-Ins). 2) Reboot. 3) Try on another machine. 4) Close Project, rename global.mpt to set it aside, and start with a fresh global file (in case it got corrupted). Commented Jan 26, 2018 at 19:04

3 Answers 3

0

Export your module, open it in Notepad or Notepad++. Scroll to the definition for your macro procedure; there should be an Attribute instruction or two on the first lines of the body of your macro:

Public Sub DoSomething()
Attribute DoSomething.VB_Description = "Does something"
Attribute DoSomething.VB_ProcData.VB_Invoke_Func = "A\n14"
    MsgBox "Hello"
End Sub

Here \n14 stands for the Ctrl+Shift key combination, so this DoSomething macro is assigned to Ctrl+Shift+A.

If the VB_ProcData attribute isn't there, add it. Note that the syntax for member attributes requires the member name to qualify the attribute (i.e. procedure name is DoSomething, so the attribute instruction goes DoSomething.VB_ProcData...).

Then save the file, go back to your VBA project, remove the module, and import the modified file.

6
  • Done. No change.
    – Greg Viers
    Commented Jan 26, 2018 at 16:07
  • @TheTTGGuy I don't have MS-Project readily available, but I'll fire up a VM when I get home tonight. The attribute should be host-agnostic (tested this in Excel), but a given host has all rights to ignore them. Is there a Macros window with an Options button? Does this Options button bring up a little dialog where you can enter a shortcut key (and a description)? Commented Jan 26, 2018 at 16:10
  • Yes. When I add a shortcut key, the shortcut key does nothing.
    – Greg Viers
    Commented Jan 26, 2018 at 16:10
  • Ok. That dialog's job is to write these hidden Attribute values in the module. Presumably if it's there, then shortcut keys should be honoured by the host app. Is there anything on Microsoft User Voice about it? Commented Jan 26, 2018 at 16:15
  • I thought that was only for Office 365. This is Project 2010. In any case, Google turned up nothing.
    – Greg Viers
    Commented Jan 26, 2018 at 16:18
0

This turned out to be an issue with the configuration of my windows profile with the corporate network here. Within project, there are 2 copies of my global template showing, one was "Global.MPT" the other was "Global (+ non-cached enterprise". Moving my macros into the second was resolved this problem.

-1

I found this problem when adding a Macro to a quicklink in MSP Pro 2016.

The macro was recorded rather than coded directly and creating a new Macro (e.g. the DoSomething() example in Mathieu's answer) worked.

Copying the macro code into Notepad, deleting the original macro and creating a new version by pasting or typing the text in worked.

Sub Baselining()

    baselineSave All:=True, Copy:=0, Into:=0
    baselineSave All:=True, Copy:=0, Into:=14

End Sub
1
  • I have tried this already, with no effect. Sorry.
    – Greg Viers
    Commented Jul 23, 2018 at 16:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .