Solved

Word 2010 ActivePrinter property case sensitive

Posted on 2011-02-11
1
2,940 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

Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.

685 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