Johan Ahlqvist
Johan Ahlqvist

Reputation: 346

VBA Application.Run returns error 1004 The macro may not be available in this workbook or all macros may be disabled

I have a VBA project which uses two workbooks on the same time. In workbook A, a module calls a module from workbook B like this:

If oED Is Nothing Then 
      Set oED = Application.Run("'" & workbookB & "'!wbB.MainModule.InitDatabaseObject")
End If

This has previously worked fine, but suddenly (apparently) this line of code doesn't find the module/macro in the other workbook.

I get this error message

Error 1004. The macro may not be available in this workbook or all macros may be disabled.

I have tried to:

When my work colleague runs the same workbooks on his computer, this works fine.

Does anyone have a clue what's going on?

Br, Johan

Upvotes: 3

Views: 1401

Answers (1)

Johan Ahlqvist
Johan Ahlqvist

Reputation: 346

Found the culprit. The workbookB simply didn't compile. After correcting it and making sure it compiled the Application.Run worked fine.

Upvotes: 1

Related Questions