ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   printing via vba (https://www.excelbanter.com/excel-programming/314910-printing-via-vba.html)

neowok[_78_]

printing via vba
 

right thanks. I've decided to use Franks approach and create a userfor
where the user selects which printer they want and then the correc
sheets in the spreadsheet are printed to that printer, so i have trie
to use this code

If UserForm1.OptionButton1.Value = True Then Application.ActivePrinte
= "\\TLPRWFC020001\tlnpwfc020001"

however i get an error when it runs saying "Method 'Activeprinter' o
object '_Application' failed".

any ideas whats wrong with my line of code?

thank

--
neowo
-----------------------------------------------------------------------
neowok's Profile: http://www.excelforum.com/member.php...nfo&userid=594
View this thread: http://www.excelforum.com/showthread.php?threadid=27202


keepITcool

printing via vba
 
select the printer manually.

now type in the immediate pane..
?application.activeprinter

you'll need to use the full string returned in the imm.pane
INCLuding the 16bit port Id. (Net01: or similar)




keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


neowok wrote:


right thanks. I've decided to use Franks approach and create a userform
where the user selects which printer they want and then the correct
sheets in the spreadsheet are printed to that printer, so i have tried
to use this code

If UserForm1.OptionButton1.Value = True Then Application.ActivePrinter
= "\\TLPRWFC020001\tlnpwfc020001"

however i get an error when it runs saying "Method 'Activeprinter' of
object '_Application' failed".

any ideas whats wrong with my line of code?

thanks




James Cox[_2_]

printing via vba
 
Neowok -

Alternately, you can invoke the Excel dialog and let your user select from
the known printers

strOldActivePrinter = Application.ActivePrinter
Application.Dialogs(9).show

If you want to capture the name by which Excel knows the selected printer -
you could also set a text
box's text to the new value

strNewActivePrinter = Application.ActivePrinter

After you print the selected sheets, be sure to return the ActivePrinter to
its original setting with

Application.ActivePrinter = strOldActivePrinter

Otherwise, your users will curse your name : )

James Cox


"neowok" wrote in message
...

right thanks. I've decided to use Franks approach and create a userform
where the user selects which printer they want and then the correct
sheets in the spreadsheet are printed to that printer, so i have tried
to use this code

If UserForm1.OptionButton1.Value = True Then Application.ActivePrinter
= "\\TLPRWFC020001\tlnpwfc020001"

however i get an error when it runs saying "Method 'Activeprinter' of
object '_Application' failed".

any ideas whats wrong with my line of code?

thanks


--
neowok
------------------------------------------------------------------------
neowok's Profile:

http://www.excelforum.com/member.php...fo&userid=5940
View this thread: http://www.excelforum.com/showthread...hreadid=272024





All times are GMT +1. The time now is 03:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com