csv - In VBA, how do I use ADODB to query the same file on a hard drive at the same time? -
i have vba code looks , aim query csv file , bring records. however, want able query same file (which sits on network drive) @ same time 2 computers. tried using readonly mode still doesn't work. please help?
dim cnt_string string cnt_string = "provider = microsoft.jet.oledb.4.0;" & _ "data source=" & "v:\data\;" & _ "extended properties = text;" strsql = "select * " & strdata & ".csv " & strdata & " (" & strdata & ".application_assigned_to='" & strbrokernumber & "')" sheets("broker").activate dim rs adodb.recordset set rs = new adodb.recordset call rs.open(strsql, cnt_string, cursortypeenum.adopenforwardonly, locktypeenum.adlockreadonly, commandtypeenum.adcmdtext) dim sh worksheet set sh = sheets("broker") call sh.range("a10").copyfromrecordset(rs) rs.close set rs = nothing
it may easier make local temporary copy of csv , import that.
if that's not practical due size of .csv, check see if file locked user , sit in loop until becomes available.
Comments
Post a Comment