excel - Issue in Running imported Macros in VBA -


i want import macro files specified location in workbooks in specified folders , want run macros on each workbook, able import in workbooks through code mentioned below can not able run macros.

sub recursivefolders()     dim filesys object     dim objfolder object     dim objsubfolder object     dim objfile1 scripting.file     dim wkbopen workbook     dim szimportpath string     dim objfso scripting.filesystemobject     dim cmpcomponents vbide.vbcomponents      set objfso = new scripting.filesystemobject     set filesys = createobject("scripting.filesystemobject")     set objfolder = filesys.getfolder("c:\users\yashika vaish\desktop\testform")      application.screenupdating = false      each objsubfolder in objfolder.subfolders         each objfile in objsubfolder.files              set wkbopen = workbooks.open(filename:=objfile)             szimportpath = folderwithvbaprojectfiles & "c:\macros"             set cmpcomponents = wkbopen.vbproject.vbcomponents              each objfile1 in objfso.getfolder(szimportpath).files                  if (objfso.getextensionname(objfile1.name) = "cls") or _                    (objfso.getextensionname(objfile1.name) = "frm") or _                    (objfso.getextensionname(objfile1.name) = "bas")                     cmpcomponents.import objfile1.path                 end if             next objfile1              application.displayalerts = false              msgbox "import ready"             application.run "headerchange_user_financial_input"             application.run headerchange_user_financial_input             application.run headerchange_user_operation_input             application.run selectrangeunitmap             application.run reportingunitmap             application.run headerchange_finacial_standard             application.run headerchange_operation_standard             wkbopen.close savechanges:=true         next     next      application.screenupdating = true     application.displayalerts = true end sub 

this code gives me pop can't run macros,

it may not available or macros disabled

but there no password , protection why not able run macros, kindly help.

you need include workbook name when calling macro (not tested):

strfile = activeworkbook application.run "'" & strfile.name & "'!headerchange_user_financial_input" 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -