W
WordVBAProgrammer
The code below works on, say, 99 out of 100 machines, regardless of
the version of Word.
I suspect a DLL is missing on the target machine, or a flaw in my
code. We are not allowed to distribute DLL files or in any other way
change a user's machine.
The code below opens a text file (SBAOffices.txt) and parses through
to populate a combobox.
Dir checks to see if the file exists. It does. strDB is the Temp or
Templates directory.
The code fails on rs.Open. Record count is 0.
Any ideas or comments to help with the thought process would be
appreciated.
Thanks!
Dan
==========================
Count = 0
If Dir(strDestination, vbNormal) <> "" Then
'Get count of records in file
If strDB = "" Then
strDB = ActiveDocument.AttachedTemplate.Path
End If
Set rs = CreateObject("ador.recordset")
strConnect = _
"Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"DefaultDir=" & strDB & ";" & Chr(34)
rs.Open "Select * from " & strTable & " order by ST, Name",
strConnect, adOpenStatic
Count = rs.RecordCount
If Count = 0 Then
GoTo ErrorOfficesList
End If
ReDim OfficeList(Count, 7)
'14 columns in SBAOffices.txt
' Access and read Text file
Do Until rs.EOF
For Each fld In rs.Fields
If fld = Empty Then
Else
....
==========================
the version of Word.
I suspect a DLL is missing on the target machine, or a flaw in my
code. We are not allowed to distribute DLL files or in any other way
change a user's machine.
The code below opens a text file (SBAOffices.txt) and parses through
to populate a combobox.
Dir checks to see if the file exists. It does. strDB is the Temp or
Templates directory.
The code fails on rs.Open. Record count is 0.
Any ideas or comments to help with the thought process would be
appreciated.
Thanks!
Dan
==========================
Count = 0
If Dir(strDestination, vbNormal) <> "" Then
'Get count of records in file
If strDB = "" Then
strDB = ActiveDocument.AttachedTemplate.Path
End If
Set rs = CreateObject("ador.recordset")
strConnect = _
"Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"DefaultDir=" & strDB & ";" & Chr(34)
rs.Open "Select * from " & strTable & " order by ST, Name",
strConnect, adOpenStatic
Count = rs.RecordCount
If Count = 0 Then
GoTo ErrorOfficesList
End If
ReDim OfficeList(Count, 7)
'14 columns in SBAOffices.txt
' Access and read Text file
Do Until rs.EOF
For Each fld In rs.Fields
If fld = Empty Then
Else
....
==========================