add in - Excel add-in doesn't work in workbooks that are running on HPC cluster -
i'm working on project moving excel calculations on hpc cluster, fine, later business required use existing excel add-ins (some .xla files), know excel workbook won't automatic load add-ins when running in excel container on hpc cluster. wrote below vba script in thisworkbook:
private sub workbook_open() dim foundmyaddin boolean dim myaddin addin each myaddin in addins if lcase(myaddin.name) = "myaddin.xla" foundmyaddin = true end if next if not foundmyaddin set myaddin = application.addins.add("c:\myaddins\myaddin.xla") myaddin.installed = true end if end sub
and put myaddin.xla in c:\myaddins on each compute node. got add-in loaded in wokbook running on cluster cells used macros in add-in actuall returned -2146826259
( meant #name$
). workbook put in shared folder, \cn01\hpcexcelsvc. wrote below script in workbook include link , add-in status in returned data
public function hpc_execute(data variant) variant dim result variant // other calculation code each lk in thisworkbook.linksources(xllinktypeexcellinks) result(1, 4) = lk exitfor next lk dim ai addin each ai in addins if lcase(ai.name) = "myaddin.xla" exit end if next if not ai nothing result(1, 5) = ai.name result(1, 6) = ai.fullname result(1, 7) = ai.installed end if hpc_execute = result
end function
i found full name c:\myaddins\myaddin.xla
, next parameter true
means add-in loaded. link not
c:\myaddins\myaddin.xla
instead was
\\cn01\myaddins\myaddin.xla
meaning cell formula =myfunc() (myfunc macro defined in myaddin.xla) became
\\cn01\myaddins\myaddin.xla!myfunc()
so added block vba script in workbook_open() update link following: if isempty(thisworkbook.linksources(xllinktypeexcellinks)) exit sub
dim lk variant each lk in thisworkbook.linksources(xllinktypeexcellinks) if not left(lk, 3) = "c:\" , lcase(lk) "*myaddin.xla" thisworkbook.changelink lk, "c:\" & right(lk, len(lk) - 7), xllinktypeexcellinks end if next lk
right(lik, len(lk) - 7)
means remove \\cn01\
prefix. update, got link returned hpc cluster as
c:\myaddins\myaddin.xla
however, still couldn't result of cell formla myfunc().
Comments
Post a Comment