简体   繁体   中英

How to fix 1004 error with macros in Excel VBA?

We have the main file on our server which contains all the VBA code and macros. We have local files in a bunch of machines in the company on which the macros from the main file are being called to start a procedure. Not sure why but recently they stopped working properly. Does anyone have any ideas on how to fix this?

I checked the macros settings and they are enabled on all computers so this is not the case. It was working fine last week but it all started in this week.

Private Sub CommandButton_CreatePanelTest_Click()
    Application.Run ("'Y:\XXX\Main.xlsm'!CreatePanelMacro")
    IgnoreReadOnlyRecommended = False
    Workbooks(Dir("Y:\XXX\Main.xlsm")).Close Savechanges:=False
End Sub

Open the workbook before you run a macro in it.

Dim Wb As Workbook
Set Wb = Workbooks.Open("Y:\XXX\Main.xlsm")
Application.Run "'Main.xlsm'!CreatePanelMacro"
IgnoreReadOnlyRecommended = False
Wb.Close SaveChanges:=False

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