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
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