Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error running a Word macro on NT

Status
Not open for further replies.

PushCode

Programmer
Dec 17, 2003
573
US
I'm trying to run a Word macro on an NT 4 server and I'm getting an error. When I run it on a 2000 server it works properly, without error.

I'm initiating the macro by executing a batch file. When I execute the batch file, Word opens, then I get the Microsoft Visual Basic window, with "Run-time error... [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"

When I click on Debug, it opens up the macro and highlights the following line as the problem:
cn.Open strConnectionString, strUserName, strUserPassword

Do I need to handle the database access differently for win NT 4? Anyone see what I've done wrong here? Here's the entire code for the macro:

Sub file_printer()

'Open any default page
Documents.Add

'Turn off Print Background
Options.PrintBackground = False

'Declare variables
Dim cn
Dim Rst
Dim strConnectionString
Dim strUserName
Dim strUserPassword
Dim sql
Dim filename As String

'Set SQL Connection
strConnectionString = "dsn=srint3;"
strUserName = "admin"
strUserPassword = "tester"

Set cn = CreateObject("ADODB.Connection")
sql = "select file_name from contact.dbo.contact_cob_file_print where printed = 0"
cn.Open strConnectionString, strUserName, strUserPassword
Set Rst = cn.Execute(sql)

'Loop recordset and print pages
Do While Not Rst.EOF
filename = Rst("file_name")
ActivePrinter = "\\DS2\Xerox DC 425 duplex on NE09:"
Application.PrintOut filename:=filename
Rst.MoveNext
Loop

'Close word
Application.Quit

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top