×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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!
  • Students Click Here

*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

Jobs

When File Print is activated run macro Word VBA 2010

When File Print is activated run macro Word VBA 2010

When File Print is activated run macro Word VBA 2010

(OP)
Hi All;

I am having an issue with some coding in Word VBA 2010. The goal is to run code when the word form is printed. I have three sections of code that I am trying to run if there are different types of printing that occur.

The form is locked. I'd like the form to unlock and shrink a button so that it has limited viability or is hidden when the file is printed. The code FilePrint_1 works just fine. The issue is that the call function is not occurring when the file is printed. This causes FilePrint_1 not to work.

Any ideas as what may be causing this code not to work?

I have tried to run the code without the form being locked and commenting out the lock / unlock process. This also didn't work.

Thanks for the help!

CODE

Sub FilePrint() 'File > Print

Call FilePrint_1

End Sub 

CODE

Sub FilePrintDefault() ' Print Button

ActiveDocument.Unprotect Password:="logspec"

Call FilePrint_1

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, Noreset:=True, Password:="logspec"

End Sub 

CODE

Private Sub FilePrint_1()

    ActiveDocument.Unprotect Password:="logspec"

                spellchecker.BackColor = &HFFFFFF
                Me.spellchecker.ForeColor = &HFFFFFF

                Me.spellchecker.Height = 1.75
                Me.spellchecker.Width = 1.75
                Me.spellchecker.BackStyle = 1


                    ActivePrinter = ""
                    Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
                        wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _
                        wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _
                        PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
                        PrintZoomPaperHeight:=0


                Me.spellchecker.BackColor = &HE0E0E0
                Me.spellchecker.ForeColor = &H80000012

                Me.spellchecker.Height = 21.95
                Me.spellchecker.Width = 79.3
                Me.spellchecker.BackStyle = 0

    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, Noreset:=True, Password:="logspec"

End Sub 

RE: When File Print is activated run macro Word VBA 2010

>shrink a button so that it has limited viability or is hidden

Why not just set it to Hidden Text? By default items configured as Hidden Text display on screen, but do not print.

RE: When File Print is activated run macro Word VBA 2010

(OP)
Hi Strongm,

Unfortunately this is a button and doesn't have the property to be set as hidden text. If there is a way that you know of, I am all ears.

Thanks,

Mike

RE: When File Print is activated run macro Word VBA 2010

(OP)
Hi Strongm,

I researched your suggestion a little more and it did work. My previous attempt didn't properly create the hidden font properly.

That did create the correct result.

Thank you very much!

Mike

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!

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