×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Word 2010 Printing Issue

Word 2010 Printing Issue

Word 2010 Printing Issue

(OP)
Dear All,

I've been using this code snippet from MS in Office 2003, 2007 and its been working fine no issues. I've upgraded to Office 2010 and the code not working I think I've found why but can't think of the way around it any help would be gladly received.

Line 3     sCurrentPrinter = Trim$(Left$(ActivePrinter, _
        InStr(ActivePrinter, " on ")))
This in office 2003/2007 shows  sCurrnetPrinter  as the local printer yet in 2010 it does not the InStr(ActivePrinter, " on "))) Functions shows the active printer and port " on " Port Name yet using 2010 it only shows the printer name.


Public Function GetBinNumbers() As Variant

    'Code adapted from Microsoft KB article Q194789
    'HOWTO: Determine Available PaperBins with DeviceCapabilities API
    Dim iBins As Long
    Dim iBinArray() As Integer
    Dim sPort As String
    Dim sCurrentPrinter As String
    'Get the printer & port name of the current printer
    sPort = Trim$(Mid$(ActivePrinter, InStrRev(ActivePrinter, " ") + 1))
    sCurrentPrinter = Trim$(Left$(ActivePrinter, _
        InStr(ActivePrinter, " on ")))
    'Find out how many printer bins there are
    iBins = DeviceCapabilities(sCurrentPrinter, sPort, _
        DC_BINS, ByVal vbNullString, 0)
    'Set the array of bin numbers to the right size
    ReDim iBinArray(0 To iBins - 1)
    'Load the array with the bin numbers
    iBins = DeviceCapabilities(sCurrentPrinter, sPort, _
    DC_BINS, iBinArray(0), 0)
    'Return the array to the calling routine
    GetBinNumbers = iBinArray
End Function

 

RE: Word 2010 Printing Issue

(OP)
Think I may have sorted this myself, In word 2010 the .activeprinter only uses the printer name and the port is left off I added the following code it does rely on excel eing install but its a work around.

Public Function GetBinNumbers2010() As Variant

    'Code adapted from Microsoft KB article Q194789
    'HOWTO: Determine Available PaperBins with DeviceCapabilities API
    'code added by SL to over come port removal from office 2010 active printer
    Dim iBins As Long
    Dim iBinArray() As Integer
    Dim sPort As String
    Dim sCurrentPrinter As String
    
    'Code Added to Overcome Word 2010 Issue
    Dim xlapp As Object
    Dim bstartApp As Boolean
        On Error Resume Next
            Set xlapp = GetObject(, "excel.Application") 'note the call to excel
        If Err Then
            bstartApp = True
            Set xlapp = CreateObject("excel.Application")
        End If
    On Error GoTo 0

    'Get the printer & port name of the current printer
    sPort = Trim$(Mid$(xlapp.ActivePrinter, InStrRev(xlapp.ActivePrinter, " ") + 1))
    sCurrentPrinter = Trim$(Left$(xlapp.ActivePrinter, _
        InStr(xlapp.ActivePrinter, " on ")))

    'Find out how many printer bins there are
    iBins = DeviceCapabilities(sCurrentPrinter, sPort, _
        DC_BINS, ByVal vbNullString, 0)

    'Set the array of bin numbers to the right size
    ReDim iBinArray(0 To iBins - 1)

    'Load the array with the bin numbers
    iBins = DeviceCapabilities(sCurrentPrinter, sPort, _
    DC_BINS, iBinArray(0), 0)

    'Return the array to the calling routine
    GetBinNumbers2010 = iBinArray
    
    'Code Added to Overcome Word 2010 Issue
    If bstartApp = True Then
    xlapp.Quit
        End If
    Set xlapp = Nothing
    
End Function

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close