Macros disabled when trying to open and run from another workbook

McGran

New Member
Joined
Feb 25, 2009
Messages
14
The following code opens a workbook called 'Move Files' and runs the macro called 'MoveFiles'
VBA Code:
Option Explicit
Sub Open_MoveFiles()
Dim wb As Workbook

Set wb = Workbooks.Open("\\[Folder hierarchy]\Move Files.xlsm")

Application.Run "'" & wb.Name & "'! MoveFiles", 1
wb.Save
wb.Close
Set wb = Nothing

ThisWorkbook.Saved = True
Application.Quit

End Sub
Until yesterday it was working perfectly well for me on 2010 and still works for other users on 2007, 2010 and 365. It no longer works for me though, returning the error
1592560801916.png


My macros are enabled (unchanged from when the file ran correctly) but it fails when I run on either 2010 or 365. Also any attempt to manually run the 'MoveFiles' macro from this instance of the file also fails, but if I close it down and re-open the 'Move Files' workbook I can successfully run the macro.

It appears as if the call to open the 'Move Files' workbook is disabling the macros for that instance.

Any ideas what is going on and how to resolve it?
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,971
You may need to change the macro settings in OPTIONS.
Allow all macros.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,463
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Try adding:

Code:
application.automationsecurity = msoAutomationSecurityLow

before the line that opens the workbook.
 

McGran

New Member
Joined
Feb 25, 2009
Messages
14

ADVERTISEMENT

Legend.

I'm still no closer to understanding why it suddenly stopped working but it works, and that's good enough for me.

Cheers
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,463
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
I suspect something got updated on your computer that altered that setting to disable macros when you open other workbooks in code.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,556
Messages
5,625,498
Members
416,113
Latest member
Zulwaqar88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top