Before Print Event

  • hi guys. I need to run a "BeforePrint" event. I have already made one:


    Code
    Private Sub DocumentBeforePrint()
            With Selection.ParagraphFormat
        Selection.WholeStory
        Selection.Font.Name = "Verdana"
        Selection.Font.Size = 10


    what i need to know is how to make the before print work. any ideas? thanks.

  • Re: Before Print Event


    I'm not sure if the BeforePrint event in Word is any different to the one in Excel, but if they behave the same, then simply pressing CTRL+P or going to File/Print will active the BeforePrint event. This event is run BEFORE the Print dialog box appears.


    HTH
    Ger

    _______________________________________________
    There are 10 types of people in the world. Those that understand Binary and those that dont. :P


    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25... ;)

    _______________________________________________

  • Re: Before Print Event


    Honestly not sure... not sure what your code is specifically trying to do, but you could jam in a msbox statement to see if it pops up before printing anything. That at least will tell you if the event is being triggered.


    Ger

    _______________________________________________
    There are 10 types of people in the world. Those that understand Binary and those that dont. :P


    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25... ;)

    _______________________________________________

  • Re: Before Print Event


    okay so lets say:


    Code
    Private Sub Workbook_BeforePrint()
    
    
    msgbox "HELLO"
    
    
    End Sub


    this doesnt even what to work. i will note that it is in a module.

  • Re: Before Print Event


    Reading up on this subject it seems that it isn't as simple as with Excel. You have to trap an event. This seems the best explanation


    See if this helps

  • Re: Before Print Event


    thanks roy, it works! the only problem now is that i need it to start when the application opens and it doesnt seem to want to.


    i thought i had to use the

    Code
    Private Sub Document_Open()

    event, problem is i get a strange error message appear!


    I read the document you linked to aswell, the

    Code
    Public Sub AutoExec()()

    doesnt work unless you manually run it?


    any ideas? thanks.

  • Re: Before Print Event


    I found that as well, Word VBa is nothing like Excel's. There is a Document_Open event, maybe move the auto_exec code to there.

  • Re: Before Print Event


    Thanks for all your help guys. (Thanks Roy) I managed to get it working by moving the

    Code
    autoexec()

    code to the "ThisDocument" window and tweaking it slightly. thanks again!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!