Solved

Word 2010 ActivePrinter property case sensitive

Posted on 2011-02-11
1
2,927 Views
Last Modified: 2012-05-11
Hi,

We use VBA macro's in Word to change the printer before printing a document.

     Application.ActivePrinter = "\\server\printer"

This code has worked since WordXP however in Word 2010 the server part became case sensitive. Therefore the following will work ...
     Application.ActivePrinter = "\\server\printer"
but this will not work
     Application.ActivePrinter = "\\Server\printer"
resulting in Error 5216

To make things worse on the same Windows 2003 network, the case changes from pc to pc so the code will work on one computer but the case needs te be different on another.



0
Comment
Question by:dataconsult01
1 Comment
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 34878156
You could look for the printer name with the expected capitalisation with this function.
Function GetPrinter(strMyCasePrinter As String) As String
    Dim WshNetwork As Object
    Dim Printers As Object
    Dim printer As Variant
    Set WshNetwork = CreateObject("WScript.Network")
    Set Printers = WshNetwork.EnumPrinterConnections
    For Each printer In Printers
        If UCase$(strMyCasePrinter) = UCase$(printer) Then
            GetPrinter = printer
            Exit For
        End If
    Next
End Function

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question