Saltar al contenido
PROGRAMAR EN VBA MACROS DE EXCEL

Macro selecciona impresora mediante cuadro diálogo


(adsbygoogle = window.adsbygoogle || []).push({});

En este post te voy mostrar una macro que permite seleccionar impresora desde un cuadro de diálogo previo a la impresión, es decir sirve para el caso que se requiera imprimir en otra impresora distinta a la activa y se desee seleccionar previamente la impresora manualmente.

Antes de seguir recomiendo leer un excelente libro sobre Excel que te ayudará operar las planillas u hojas de cálculo, haz click acá, si quieres aprender sobre Excel, en inglés, entonces debes hacer click here. Si lo que necesitas es aprender o profundizar sobre la programación de macros con VBA este es unos de los mejores cursos on line que he visto en internet.

  

El ejemplo de macro tiene como fin poder seleccionar la impresora que deseamos previo a la impresión, existen varios post relacionados con toda esta saga de artículos relacionados con macros para imprimir en Excel como son: imprimir una hoja del libro de Excelcomo configurar una hoja de Excel mediante macro, imprimir en una impresora distinta a la que se encuentra por defecto.

La macro de ejemplo permite imprimir la hojas del libro de Excel, previo a ello da la opción al operador de seleccionar la impresora en la que desea se imprima el trabajo, el ejemplo específicamente primero, solicita se elija la impresor donde se imprimirá el trabajo, luego configura la página para imprimir y por último emite la orden para imprimir.

Al seleccionar la impresora en el cuadro de diálogo se modifica la impresora activa, es por ello que para dejar todo en el orden que estaba, se carga en una variable el nombre de la impresora activa, luego con el siguiente comando se presenta el cuadro de diálogo para elegir la impresora:
Application.Dialogs(xlDialogPrinterSetup).Show

Seleccionada la impresora se procede a configurar página con los margenes necesarios, pie de página, encabezado de página, disposición u orientación de la página, etc.; posterior se imprime la hoja del libro activo con el siguiente código, solicitando en los argumentos se impriman dos hojas, se intercale y no se ignore área de impresión.

ActiveSheet.PrintOut Copies:=2, Collate:=True, IgnorePrintAreas:=False

Por último con este código volvemos a seleccionar la impresora activa que estaba originalmente:
Application.ActivePrinter = def

Desde el link final podrás descargar el ejemplo totalmente GRATUITO denominado Macro selecciona impresora mediante cuadro de diálogo, recordando que si este o alguno de los cientos de ejemplos publicados te fueron de utilidad y puedes, aporta a seguir manteniendo esta página.


El vídeo que sigue muestra una explicación más detallada y gráfica de la macro presentada, recomiendo observar para una más fácil comprensión de la macro; suscribe a nuestra web desde la parte superior derecha de la página ingresando tu mail y a nuestro canal de You Tube para recibir en tu correo vídeos explicativos sobre macros interesantes, como  por ejemplo formulario que crea un listado de todas las hojas para poder luego seleccionarlasbuscar en listbox mientras escribes en textboxordenar hojas libro excel por su nombreconectar Excel con Access y muchos ejemplos más.

function onYtEvent(payload) {
if (payload.eventType == ‘subscribe’) {
// Add code to handle subscribe event.
} else if (payload.eventType == ‘unsubscribe’) {
// Add code to handle unsubscribe event.
}
if (window.console) { // for debugging only
window.console.log(‘YT event: ‘, payload);
}
}

Código que se inserta en un módulo


Sub PrintSelection()
Dim def As String
def = Application.ActivePrinter
Application.Dialogs(xlDialogPrinterSetup).Show
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
        .PrintTitleRows = «»
        .PrintTitleColumns = «»
    End With
    Application.PrintCommunication = True
    ActiveSheet.PageSetup.PrintArea = «»
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
        .LeftHeader = «»
        .CenterHeader = «»
        .RightHeader = «»
        .LeftFooter = «»
        .CenterFooter = «»
        .RightFooter = «»
        .LeftMargin = Application.InchesToPoints(0.7)
        .RightMargin = Application.InchesToPoints(0.7)
        .TopMargin = Application.InchesToPoints(0.75)
        .BottomMargin = Application.InchesToPoints(0.75)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlPortrait
        .Draft = False
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 0
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = «»
        .EvenPage.CenterHeader.Text = «»
        .EvenPage.RightHeader.Text = «»
        .EvenPage.LeftFooter.Text = «»
        .EvenPage.CenterFooter.Text = «»
        .EvenPage.RightFooter.Text = «»
        .FirstPage.LeftHeader.Text = «»
        .FirstPage.CenterHeader.Text = «»
        .FirstPage.RightHeader.Text = «»
        .FirstPage.LeftFooter.Text = «»
        .FirstPage.CenterFooter.Text = «»
        .FirstPage.RightFooter.Text = «»
    End With
    Application.PrintCommunication = True
    ActiveSheet.PrintOut Copies:=2, Collate:=True, IgnorePrintAreas:=False
    Application.ActivePrinter = def
End Sub

Si te fue de utilidad puedes INVITARME UN CAFÉ y de esta manera ayudar a seguir manteniendo la página, CLICK para descargar en ejemplo en forma gratuita.


(adsbygoogle = window.adsbygoogle || []).push({});

If this post was helpful INVITE ME A COFFEE and so help keep up the page, CLICK to download free example.

Si te gustó por favor compártelo con tus amigos
If you liked please share it with your friends      

Entradas relacionadas

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Comentarios (35)

Hi there, its good paragraph concerning media print, we all
know media is a wonderful source of facts.

Responder

Excellent post. I was checking constantly this
weblog and I am impressed! Very useful information specially the remaining part :
) I take care of such info much. I used to be seeking this particular info for a very
long time. Thank you and best of luck.

Responder

Undeniably believe that which you said. Your favorite
reason appeared to be on the net the easiest thing to
be aware of. I say to you, I certainly get annoyed while people think
about worries that they just don’t know about. You managed to hit the
nail upon the top as well as defined out the whole thing without having side-effects , people could
take a signal. Will likely be back to get more. Thanks

Responder

This is my first time go to see at here and i
am actually happy to read all at single
place.

Responder

Hello very nice website!! Guy .. Excellent .. Superb .. I’ll bookmark your web site and take the
feeds additionally? I’m happy to seek out a lot of helpful information right here in the
publish, we need work out more techniques in this regard, thanks for sharing.

. . . . .

Responder

Thankfulness to my father who informed me about this webpage, this webpage
is really amazing.

Responder

Fine way of telling, and good article to
get data regarding my presentation subject, which
i am going to convey in university.

Responder

Great beat ! I wish to apprentice even as you amend your
website, how could i subscribe for a blog site?
The account helped me a appropriate deal. I have been tiny bit acquainted of this your broadcast offered bright transparent concept

Responder

I was able to find good advice from your content.

Responder

We’re a bunch of volunteers and starting a brand
new scheme in our community. Your website offered us with helpful information to work on.
You’ve done a formidable activity and our whole neighborhood will be thankful
to you.

Responder

Stunning story there. What happened after? Take care!

Responder

I really like it when people get together and share views.

Great website, continue the good work!

Responder

This post is genuinely a good one it assists new net users, who are wishing for blogging.

Responder

Hi everyone, it’s my first go to see at this web site, and post
is actually fruitful in favor of me, keep up posting these types of articles.

Responder

I like it when individuals come together and share opinions.
Great website, keep it up!

Responder

Keep this going please, great job!

Responder

Thanks on your marvelous posting! I truly enjoyedreading it, you’re a great author. I will remember to bookmark your blog andmay come back from now on. I want to encourageone to continue your great work, have a nice holiday weekend!

Responder

Thanks for another informative blog. The place else may I get that kind
of info written in such an ideal way? I’ve a venture that I am just now running on, and I have been on the glance out for such info.

Responder

You’ve made some decent points there. I looked on the internet to learn more about the issue
and found most individuals will go along with your views on this web site.

Responder

You actually make it seem so easy with your presentation but I
to find this matter to be actually something that I think I might by no means understand.

It sort of feels too complex and extremely extensive for me.

I’m looking forward to your next publish, I will attempt to get the grasp of it!

Responder

I like what you guys are up too. This type of clever work and coverage!
Keep up the wonderful works guys I’ve included you guys to my personal blogroll.

Responder

Hello There. I found your blog the usage of msn. This is a
really well written article. I will be sure to bookmark it and return to read
more of your useful information. Thank you for the post. I will certainly
return.

Responder

Fantastic blog! Do you have any recommendations for aspiring
writers? I’m planning to start my own site soon but I’m a little lost on everything.
Would you propose starting with a free platform like
Wordpress or go for a paid option? There are
so many options out there that I’m completely overwhelmed ..
Any recommendations? Thanks!

Responder

I think this is among the most significant info for me.
And i’m glad reading your article. But want to remark on few general things, The website style
is wonderful, the articles is really excellent : D. Good job, cheers

Responder

What’s Happening i’m new to this, I stumbled upon this I
have found It absolutely useful and it has aided me out loads.
I hope to give a contribution & aid different customers like its aided me.
Good job.

Responder

Nice replies in return of this matter with real arguments and
explaining the whole thing on the topic of that.

Responder

Thanks to my father who shared with me concerning this web site, this
weblog is really remarkable.

Responder

Hi! I know this is kinda off topic however , I’d
figured I’d ask. Would you be interested in exchanging links or maybe guest
authoring a blog article or vice-versa? My blog discusses a lot of the same topics as yours
and I think we could greatly benefit from each other.
If you’re interested feel free to shoot me an email.

I look forward to hearing from you! Terrific blog by the way!

Responder

It’s truly very complicated in this busy life to listen news on Television, so I only use
internet for that purpose, and take the hottest news.

Responder

I like what you guys are up too. This sort of clever work and reporting!
Keep up the superb works guys I’ve incorporated you guys to my own blogroll.

Responder

Hi, I do think this is a great web site. I stumbledupon it 😉 I’m going to come back yet again since I book-marked it.
Money and freedom is the greatest way to change,
may you be rich and continue to help others.

Responder

Wonderful blog! Do you have any tips and hints for aspiring
writers? I’m planning to start my own blog soon but I’m a little lost on everything.
Would you recommend starting with a free platform like WordPress or go for a paid
option? There are so many options out there that I’m totally overwhelmed
.. Any tips? Appreciate it!

Responder

Hola! I’ve been reading your site for some time now and finally got the bravery to go ahead and give you a shout
out from Dallas Texas! Just wanted to mention keep up the good job!

Responder

hey there and thank you for your info – I’ve certainly
picked up something new from right here. I did however expertise some technical issues using this website, as I
experienced to reload the web site a lot of times previous to I could
get it to load properly. I had been wondering if your hosting is OK?
Not that I am complaining, but slow loading instances times will sometimes affect
your placement in google and can damage your quality score if advertising and marketing with Adwords.
Well I am adding this RSS to my e-mail and could look out for a lot more of your respective exciting content.

Make sure you update this again very soon.

Responder

I’ve been browsing on-line more than three hours as of late, but I
by no means found any interesting article like yours.
It is lovely worth sufficient for me. In my view, if all webmasters and bloggers made just right content
as you probably did, the web will be a lot more useful than ever before.

Responder