VBA Application.Run语法

时间:2017-01-12 14:08:29

标签: vba

我有一个加载项,我想从另一个工作簿中调用。加载项称为" status"并放在文件夹"测试"。加载项中的Sub称为Workbook_AfterSave。

我要调用的Sub是这样启动的:

Application.Run "Test\status.xlam!Workbook_AfterSave"

调用特定Sub的正确语法是什么?我想:

var data= [
      { project: "ABC",    area: 'Test',       subArea: 'Dev',     done: 10 },
      { project: "ABC",    area: 'Test',       subArea: 'QA',      done: 10 },
      { project: "ABC",    area: 'Test',       subArea: 'Support', done: 10 },
      { project: "ABC",    area: 'External',   subArea: 'Dev',     done: 5  },
      { project: "ABC",    area: 'External',   subArea: 'QA',      done: 5  },
      { project: "ABC",    area: 'External',   subArea: 'Support', done: 5  },
      { project: "ABC",    area: 'Escalation', subArea: 'Dev',     done: 20 },
      { project: "ABC",    area: 'Escalation', subArea: 'QA',      done: 20 },
      { project: "ABC",    area: 'Escalation', subArea: 'Support', done: 20 },
      { project: "ABC123", area: 'Test',       subArea: 'Dev',     done: 20 },
      { project: "ABC123", area: 'Test',       subArea: 'QA',      done: 20 },
      { project: "ABC123", area: 'Test',       subArea: 'Support', done: 20 },
      { project: "ABC123", area: 'External',   subArea: 'Dev',     done: 10 },
      { project: "ABC123", area: 'External',   subArea: 'QA',      done: 10 },
      { project: "ABC123", area: 'External',   subArea: 'Support', done: 10 },
      { project: "ABC123", area: 'Escalation', subArea: 'Dev',     done: 5  },
      { project: "ABC123", area: 'Escalation', subArea: 'QA',      done: 5  },
      { project: "ABC123", area: 'Escalation', subArea: 'Support', done: 5  },
    ];

但这并不奏效。我收到错误消息:"宏可能不可用此工作簿或所有宏可能被禁用。"

上面的路径很简单,我确实输入了Sub的完整路径。

有什么建议吗?

亲切的问候 埃里克

1 个答案:

答案 0 :(得分:0)

Application.Run "'C:\Test\status.xlam'!ThisWorkbook.Workbook_AfterSave", True

(假设您提供的路径为卷C: