?
Solved

Word 2010 ActivePrinter property case sensitive

Posted on 2011-02-11
1
Medium Priority
?
3,000 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.

770 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