简体   繁体   中英

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:

  • Clear the macro settings in Excel
  • Clean the workbook (using a tool)
  • Delete ActiveX cache files (*.exd files)

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM