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?
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try adding:

Code:
application.automationsecurity = msoAutomationSecurityLow

before the line that opens the workbook.
 
Upvote 0
Legend.

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

Cheers
 
Upvote 0
I suspect something got updated on your computer that altered that setting to disable macros when you open other workbooks in code.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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
Back
Top