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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

W2K3 Server & Setting Active Printer using VBA

Status
Not open for further replies.

netsmurph

Technical User
Mar 19, 2003
63
GB
I have an Access db that uses vba to select type of printer to print word documents to (letterhead/duplex/etc). Recently the server has been upgraded to W2k3 and the code does not select the correct printers.

I made sure that the printer names were left the same and thought that all that i would have to do would be to change the printers so that they reflected the new server name, ie

\\Fredsv02\Brother 4200

This does not work and the active printer stays as the selected default printer.

Does anyone know how w2k3 printers must named or referenced to from VBA (ie do you need to specify a domain or another parameter?).

Any help would be appreciated as I cannot work it out!

Thanks in advance.

Andrew
 
It sees to me that the printer also need a pronter port ie. LPTx, but could I see the code so that I could check it here?


Herman
Say no to macros
 
Dim wordApp As Word.Application
Dim WordDoc As Word.Document
Dim Wordpara As Word.Paragraph

Dim db As Database
Dim rs As Recordset
Dim newSQL As String
Dim oldsql As String

Set rs = db.OpenRecordset(oldsql, dbOpenDynaset)

Set wordApp = New Word.Application

Set WordDoc = wordApp.Documents.Add(dlookup("[location]", "tbllocation", "[variable] = 'template'") & "\" & "0039.1 Phoenix Loan Letter.dot")

WordDoc.Bookmarks(1).Range = addressstring
WordDoc.Bookmarks(2).Range = rs!PaymentID
WordDoc.Bookmarks(3).Range = IIf(IsNull(rs!Title), "", rs!Title & " ") & rs!LastName

ActivePrinter = "\\fredsrv01\4200CN DUPLEX"

WordDoc.Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
 
Thx for your bit of code.
I found the following

PtPrinter = wordApp.ActivePrinter
Gets the printer now, as I am sure that you already know, using the "Locals" and looking under wordapp I see the printer changing as I set the active printer.

As long as I give "wordApp.ActivePrinter" the correct spelling of the printer, as its registred on my pc, the printer will change and print.


Herman
Say no to macros
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top