vba - Gah!! Error 424 runtime error : Object required Word Visual Basic -


im trying load contents of textfile variable titular error, searching vba knowledgebase led me belive that

set mysql = my.computer.filesystem.readalltext("c:\sql_query_temp.res") 

would solve produces 'error : object required' when run. heres code, have missed?

'requires microsoft activex data objects x.x library in references public sub connecttoodbc()      dim myconn new adodb.connection     dim myrs new recordset     dim mysql string     dim myrows long      'open file containing sql query     mysql = my.computer.filesystem.readalltext("c:\sql_query_temp.res") <----- bad!      'open connection      myconn.open "dsn=database"      'do query      myrs.source = mysql      set myrs.activeconnection = myconn      myrs.cursorlocation = aduseclient      myrs.open       'count rows       myrows = myrs.recordcount        'add text word document!       selection.typetext (myrows)        'close connection       myrs.close       myconn.close end sub 

my.computer vb.net entirely different vba instead can;

function readfile(path string) string     dim hf integer     hf = freefile()     open path input #hf         readfile = input$(lof(hf), #hf)     close #hf end function  ...  mysql = readfile("c:\sql_query_temp.res") 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -