printing a document with hyperlinks

C

Chip Orange

We have documents with hyperlinks and our users wish them to print as if the
hyperlinks weren't present, but no change to the way the hyperlinks look
onscreen.

I've been doing this with a FilePrint() intercept routine, and actually
deleting the hyperlinks, printing, and then undoing my changes. I supposed
I could edit the hyperlink style on the fly, but that's not much different,
and I seem to recall trying it and finding a problem.

I'm thinking there's got to be a more ellogant approach to this problem?

Any ideas?

Thanks.

Chip
 
J

Jay Freedman

Hi Chip,

I don't know about "more elegant", but I like modifying the style to hide
the links better than actually deleting the links -- that way if the macro
crashes, there's little to no chance of losing them permanently.

There are some details you need to take care of. Just in case the user has
set the option to print Hidden text, you should store the user's choice
before printing and restore it afterward. Also, since modifying the style
will dirty the document, you need to store the Saved property of the
document and restore that afterwards to avoid an unnecessary prompt to save.

Dim oldPrintHidden As Boolean, oldSaved As Boolean
Dim oStyle As Style

' store current save state
oldSaved = ActiveDocument.Saved

' store user's current option then set it
oldPrintHidden = Options.PrintHiddenText
Options.PrintHiddenText = False

Set oStyle = ActiveDocument.Styles("Hyperlink")

' turn off hyperlinks, print, turn on hyperlinks
oStyle.Font.Hidden = True
ActiveDocument.PrintOut Background:=False
oStyle.Font.Hidden = False

' restore old settings
Options.PrintHiddenText = oldPrintHidden
ActiveDocument.Saved = oldSaved

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
S

Shauna Kelly

Hi Chip

For what it's worth, I went through something similar recently. Users wanted
to be able to see the hyperlinks on the screen when editing, but did not
want to see them when printed. And, they wanted Print Preview to reflect
what would actually print.

So we gave them a 'Toggle hyperlink display' button that does roughly what
Jay's button does: change the Hyperlink style. In my case, we toggle the
underline on the Hyperlink style so it looks like plain text. Now the users
can determine when and how the hyperlinks show with underlines.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
C

Chip Orange

Thanks Jay.

Let me clarify something: they want to print the text within the link just
as if it were normal text in the document (what I was doing was when I
deleted the link was restoring the original text to the document).

This method below would not print the linked text, but I'm guessing I could
modify the style so that the background color and underlining was gone. Now
I remember, restoring the original text by deleting the hyperlink restored
it's original appearance, so if it had been underlined it again was
underlined. Modifying the hyperlink style didn't achieve this, so in some
cases, I had the linked text not underlined in the middle of an underlined
portion (I think that was the problem).

Now I've given you more info, have any other ideas?

Thanks again,

Chip
 
J

Jay Freedman

Hi Chip,

That's a different situation than I had in mind -- in fact, a link of a
different color <groan>.

What you're running into is the difference between style-applied formatting
and manually-applied (direct) formatting. Word behaves differently in these
two situations:

1. Start with an ordinary Normal-style paragraph. Select the whole paragraph
and apply underline format to it (Ctrl+U or the toolbar button). Now insert
a hyperlink in the paragraph. If you modify the Hyperlink style to remove
the underline from the style definition, the result won't be underlined.

2. Start with an ordinary Normal-style paragraph. Insert a hyperlink in the
paragraph. Now apply underline format to the whole paragraph. If you modify
the Hyperlink style to remove the underline from the style definition, in
this case the result will be underlined -- because the direct underlining
was applied "on top of" the underline that's part of the Hyperlink style.

Even worse, you can have both situations simultaneously in the same
document -- some hyperlinks surrounded by underlined text will stay
underlined and others won't. This mess can't be handled by style
manipulation alone. You'd have to examine the text around each link to see
whether it should be underlined when it isn't.

Interestingly, the method of deleting and restoring the hyperlink does
everything right without any further fuss. So it appears to be the "more
elegant" method after all!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top