+ Reply to Thread
Results 1 to 14 of 14

Code To Adjust With Changing Printer Location

  1. #1
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Question Code To Adjust With Changing Printer Location

    My code contains a line in where the name of a specified printer that needs to be used is located on Ne03. However, I've come across this several times where the Ne number will change for some reason unknown to me - in my case, it has now changed to Ne01, meaning all the workbooks that have been saved with Ne03 in the code are no longer working.

    I'm looking for a workaround for this problem where the code would just take the name of the printer (which won't be changing as far as I can tell) regardless of it's ending and just print, but I'm not sure how to go about this in my case. Here is my code:

    Please Login or Register  to view this content.
    Any ideas here would be greatly appreciated. Thanks in advance!
    There is so much good in the worst of us,
    And so much bad in the best of us,
    That it hardly behooves any of us
    To talk about the rest of us.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Code To Adjust With Changing Printer Location

    This is one of my pet peeves, you don't need the printer port in Word, but you do in Excel. This is the most efficient way of doing it, put the below in a module somewhere:
    Please Login or Register  to view this content.
    This is then called like this:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Code To Adjust With Changing Printer Location

    Thank you Kyle123 - I'm having a few issues getting this to work with my code - where do I put that second code in mine?

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Code To Adjust With Changing Printer Location

    Something like this:
    Please Login or Register  to view this content.
    To see what the function returns without running all the code, in the immediate window type:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Code To Adjust With Changing Printer Location

    I'm getting an error - do you have any idea what I'm doing wrong here?

    Please Login or Register  to view this content.

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Code To Adjust With Changing Printer Location

    missed the on out, try this :
    Please Login or Register  to view this content.
    What do you get when you run ?GetPrinterPort("Brother QL-1060N") in the imediate window?

  7. #7
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Code To Adjust With Changing Printer Location

    Hey! That seems to be doing it. And this may sound like a really dumb question - but how do I run ?GetPrinterPort("Brother QL-1060N") in the immediate window?

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Code To Adjust With Changing Printer Location

    have you tried typing it in.....?

  9. #9
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Code To Adjust With Changing Printer Location

    Um, haha, yes I have, but where? Typing it in the VBA window and then trying to run it gives me an error.

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Code To Adjust With Changing Printer Location

    here:
    \1
    Attached Images Attached Images

  11. #11
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Code To Adjust With Changing Printer Location

    There's a window called Immediate - who would have guessed!

    Okay, so trying to run that brings up the Macros window.

  12. #12
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Code To Adjust With Changing Printer Location

    type it in and just press enter at the end of the line to run it.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  13. #13
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Code To Adjust With Changing Printer Location

    Oh! Thank you. I get Ne03: when I do that. This is very nice, thank you so much!

  14. #14
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Code To Adjust With Changing Printer Location

    Glad it's working, thanks for the feedback

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1