Run Time Error '1004' when displaying userform

flipcube

Board Regular
Joined
Aug 29, 2011
Messages
134
Hi all,

trying to display userform2 located in Book2.xlsm from a command button located in Book1.xlsm

here is my code:

Book2 code...

Sub Z()
userform 2.show
End sub

Book1 code...

Sub commandbutton1_click()
Application.Run "'Book2.xlsm'!Z"
end sub

both workbooks are open.

I get a Run Time Error '1004': Cannot run the macro "'Book2.xlsm'!Z". the macro may not be available in this workbook or all macros are disabled.

I've done some searching online and cannot understand why i am getting the error.

I'm wondering if it has something to do with the .xlsm extension

Thanks.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
For me it works perfectly in my test.

Is Book2.xlsm the correct name? Is that file saved?
 
Upvote 0
Wigi, Norie,

yes, both files are saved and located in the same folder. I went home last night and tested it on Excel 2003 and it worked just fine. I tried it again this morning at work (Excel 2007) and it also worked.

I did not change anything from yesterday...operator error I guess.

Thanks
 
Upvote 0
Okay, fine, thanks for confirmation.
 
Upvote 0
Hi all,

It seems that now I have the same issue as described above. I moved the respective workbooks from my H: drive onto one of my company's shared drives and now I am getting the same problem described above.

nothing has changed except the file locations. any ideas what could be causing the error now?

Thanks,
Flipcube
 
Upvote 0
How are the macro enabling settings defined?

From your description, it seems as if in the macro settings:
Excel Options >> Trust Center >> Trust Center Settings >> Macro Settings
are different for Local Drives and Network Drives.
That is: Local Drives are added as Trusted Locations and Network Drives aren't.

So the workbook opened needs to be macro enabled before executing this code.
 
Upvote 0

Forum statistics

Threads
1,214,619
Messages
6,120,550
Members
448,970
Latest member
kennimack

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