Computing.Net > Forums > Windows NT > error running a Word macro on NT

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

error running a Word macro on NT

Reply to Message Icon

Name: pushcode
Date: February 26, 2004 at 06:29:59 Pacific
OS: NT 4
CPU/Ram: Pent.
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Jennifer SUMN
Date: February 28, 2004 at 18:38:31 Pacific
Reply:

Maybe this will help you:

http://www.computing.net/dos/wwwboard/forum/14596.html


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows NT Forum Home


Sponsored links

Ads by Google


Results for: error running a Word macro on NT

Can I Share a Network Drive on NT? www.computing.net/answers/windows-nt/can-i-share-a-network-drive-on-nt/17582.html

Running a batch file on Server from Clie www.computing.net/answers/windows-nt/running-a-batch-file-on-server-from-clie/14965.html

Who is using a printer share on NT 4.0? www.computing.net/answers/windows-nt/who-is-using-a-printer-share-on-nt-40/13716.html