vba - Excel 2007 Macro ,VBAProject can put a configuration file? -


firstly, i'm newer excel macro. have read articles , done work these days. i'm hesitant.can .txt or .xml file placed vbaproject?if yes,how place , how path of file or read file? if no, there transit way work? think macro,not addin project. much!

you can save txt ini extension , save settings in key value pairs. below code can retrieve settings providing key , getting value.

private declare function getprivateprofilestring lib "kernel32" alias "getprivateprofilestringa" (byval lpapplicationname string, byval lpkeyname string, byval lpdefault string, byval lpreturnedstring string, byval nsize long, byval lpfilename string) long  public function getinistring(byval sapp string, byval skey string, byval filepath string) string     dim sbuf string * 256     dim lbuf long      lbuf = getprivateprofilestring(sapp, skey, "", sbuf, len(sbuf), filepath)     getinistring = left$(sbuf, lbuf) end function  sub sample()     dim path string     path = thisworkbook.path & "\" & "path.ini"     link = getinistring("path", "link", path) end sub 

please save .ini file in same folder workbook resides or may change path variable accordingly.

enter image description here

you may refer link more details.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -