Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2007

Tip: Looking for answers? Try searching our database.

printing a document with hyperlinks

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chip Orange - 21 Sep 2007 20:13 GMT
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
Jay Freedman - 21 Sep 2007 22:19 GMT
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

Signature

Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

> 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
[quoted text clipped - 12 lines]
>
> Chip
Shauna Kelly - 22 Sep 2007 04:43 GMT
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

> Hi Chip,
>
[quoted text clipped - 46 lines]
>>
>> Chip
Chip Orange - 25 Sep 2007 18:43 GMT
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

> Hi Chip,
>
[quoted text clipped - 46 lines]
>>
>> Chip
Jay Freedman - 25 Sep 2007 20:46 GMT
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!

--
Jay

> Thanks Jay.
>
[quoted text clipped - 73 lines]
>>>
>>> Chip
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.