Excel VBA Compile Error -
we have excel spread sheet use , works machines bombs out 'compile error in hidden module - general' on others, , reason appears due missing references.
we check macros enabled still doesn't help.
since protect excel spread sheet password, don't want giving password out our users check references, , wondered if had idea how can add vba code check whether references required excel spread sheet there , if not bring message box advise user.
the references use follows:
- visual basic applications
- microsoft excel 11.0 object library
- microsoft forms 2.0 object library
- microsoft windows common controls 5.0 (sp2)
alternatively, if has other suggestions on how go problem, great.
the reference have listed possibly missing common controls. rest default in every version of excel. forms 1 if have userform or explicitly set it, that's not problem. common controls problem. doesn't ship office anymore. if have visual studio or vb6 have it. or old version of office xp developer edition.
anyway, can check existence of ocx file in system folder. don't think it's required in folder, i've never seen anywhere else.
it's been quite while since i've seen reference 5.0, included how find 6.0 in code below. check make sure know version you're using.
in standard module:
private declare function getsystemdirectory lib "kernel32" alias "getsystemdirectorya" (byval lpbuffer string, byval nsize long) long public function hascommoncontrol() boolean dim sfolder string dim lreturn long const lsize long = 255 const sdllname string = "comctl32.ocx" 'for windows common control 5.0 'const sdllname string = "mscomctl.ocx" 'for windows common control 6.0 sfolder = space(lsize) lreturn = getsystemdirectory(sfolder, lsize) sfolder = left$(sfolder, lreturn) hascommoncontrol = len(dir(sfolder & application.pathseparator & sdllname)) > 0 end function
having said that, why using common controls? if it's treeview on userform, check out all-vba treeview
http://www.jkp-ads.com/articles/treeview.asp
since jkp wrote that, haven't used common controls. few normal-people pcs have installed it's pain.
Comments
Post a Comment