excel - Can't set target worksheet from macro -


i have sub processed macros added 2 excel files , worked.

now i've learned files processed won't have these macros , should store them elsewhere. put them in empty workbook , can call macro.

the problem is, it's target (an empty workbook). need to work on excel have opened (x1)

it originally

xl.run macroname 

the macro , target worksheets contained here

now have need run on worksheets of x1, not itself.

mymacro.run macroname 'runs no worksheets here 

here full code of sub

sub preparereport(macroname string)  dim mymacro object dim xl object  dim filepath string dim filename string  filename = determinefilenameauto(macroname) filepath = currentproject.path + "\source_files\" + filename  'load macro-excel files set mymacro = createobject("excel.application") mymacro.workbooks.open (mymacrofilepath)  'load excel file, open target workbook. set xl = createobject("excel.application") xl.workbooks.open (filepath)  'run  macros   'originally  'xl.run macroname  'macros contained within file  'this run target should x1 workbook mymacro.run macroname    ' close , save workbook, close excel echobacktoform ("closing workbook")    xl.activeworkbook.close (true)    xl.quit  'step 5:  memory clean up. set xl = nothing   end sub 


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -