Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When File Print is activated run macro Word VBA 2010 1

Status
Not open for further replies.

remeng

Technical User
Jul 27, 2006
504
0
16
US
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
 
>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.
 
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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top