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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -