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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Event?

Status
Not open for further replies.

LakotaMan

Instructor
Aug 21, 2001
240
US
Hi all,

I am extremely new to this forum and don't even know how to ask this question, so I hope you'll bear with me and help point me in the right direction.

Most of my coding experience is in Access, where every object has a list of properties and events that I can code. If I want something to happen in a report, I can code several events to make it happen.

Does Word have similar "events" in VBA? I am, specifically, looking to have a graphic or some text show up only on printing, and I don't even know where to begin to look for such an event in the Word VBA window.

Help!

Any help you can give me or nudge in the right direction will be greatly appreciated.

Tru
 
Try using the Object Browser to get started. In Word, goto Tools|Macros|VB Editor and hover over the items on the ToolBar. You're looking for the one that looks like a little box with the lid open and 3 things coming out.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Hi Tru, [2thumbsup]

Don't use code for this, you just need Hidden Text!

Put the text in you're document en go to the Font Dialog en put a marker in the Hidden text box. (now the text we'l disapear)
Make shure you check the print options box for Hidden text.
TOOLS/OPTIONS/PRINT/HIDDEN TEXT.

The txt is invisible in the screen and in Print preview but it wil print when you print the document.

Enjoy,[peace]
Joost Verdaasdonk
 
Joost,

This is working GREAT!!!! Now, another question, how can I set it up so that this print setting "travels" with the document.

To explain, it will be stored on a network and printed from client copies of Word, not all of whom will have this option turned on. I have tried writing this in VBA:

Private Sub Document_Open()

Options.PrintHiddenText = True

End Sub

It turns the option on, but still doesn't print the text! Any ideas?

Again, thanks so much for the help so far!

Tru
 
Hi Tru, [thumbsup]

Seems to me you forgot to format the hidden text in the document.

You could consider to put the text in the Open event in the right format and then turn the switch on.

Note:
For A template use the AutoNew event (or Document_New)
For A document ust the AutoOpen event ("")

One other thing make shure you never put something on a users computer that he does not Know off! When you turn print hidden text on, you have to load it in a variable and use it that way en set it back the way it was in the Close event of the procedure!

I've takin this little test:
Code:
Private Sub Document_Open()
Dim strPrint As Boolean
strPrint = Options.PrintHiddenText

    Selection.TypeText Text:="Hi There,"
    Selection.MoveLeft Unit:=wdWord, Count:=3, Extend:=wdExtend
    With Selection.Font
        .Hidden = True
    End With
    Options.PrintHiddenText = True
End Sub
Private Sub Document_Close()
Options.PrintHiddenText = strPrint
End Sub
'Private Sub Document_New()
''use in a Template!
'End Sub

This worked well on my pc, please trie it at yours.
You can record the inserting off hidden text in you're template to make it easy on you're self!

Enjoy, [peace]
Joost Verdaasdonk
 
Hi Joost,

Excellent work! Thank you so much for the code example, this wraps it up quite well, as I was worried about "fiddling" with the user settings.

It works beautifully, and now I can sleep tonight. . .

Many thanks,
Tru
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top