Display hidden text only when saving as html

G

Guest

The best way to describe this question is to first describe what I am trying
to achieve.

I have a document that I want to use both in printed form and as an html
document. I would like this transition to be transparent so as not to have to
change markup back and forth each time the document is updated.

Table of Contents entries automatically become hyperlinks in the HTML
document without any effort on my part, and print normally if printing the
document. What I want to do is have other manually entered hyperlinks not
print, but still appear in the HTML document.

For example, the manual hyperlinks would be backward reference to other
parts of the document, inserted for convenience when viewing the HTML
document. In the printed document, they would serve no purpose.

They might be barely acceptable in the printed document if they had page
numbers, but then the page numbers would be meaningless in the HTML version.

So what I am trying to find is some way to enter something that acts like a
Table of Contents entry, but appears only in the HTML edition.

Unfortunately, the Index entries retain useless page numbers instead of
being converted to hyperlinks like the Table of Contents. However, a user
can simple use "Find" to locate something in an HTML document, and the Index
section can be ignored or deleted before distribution.

Is there any sort of way to have text that is conditional based on the
output format without requiring some manual operation each time?

Thanks
 
D

Daiya Mitchell

Hi Joe,

Instead of page numbers for backward reference, can you use a
cross-reference to Section 3 or something? E.g., "see chapter 6". Then the
text would be useful in either version.

Cross-references can be automatically created as hyperlinks, which do not
show the normal formatting.

By the way, Table of Contents and cross-references act as hyperlinks in a
regular Word document, even before the conversion to HTML, for ease of
reading on screen.

You've asked this question before, apparently without a satisfactory answer.
I doubt you are going to get something that automatically triggers on Save
As as you wish. However, if you are willing to run a FormatForHTML and a
FormatForPrint macro before output, you could probably get what you want
with a minimum of effort once the macros are setup, and get the macros to
include the Save As command.
 
G

Guest

Thanks for response, Daiya,

You've given me some ideas to research. I'll have to learn abut macros
first and then see if I can come up with something that would work.

it wouldn't be automatic as you say, but it would be workable.

Thanks again,
Joe
 
D

Daiya Mitchell

Hi Joe,

Actually, you don't really need to learn about macros first. You need to
sort out what you want to happen. If you are going to be deleting text, the
easiest way might be to format it in a style and then do a Find and Replace
with nothing for that style. If all the text is staying put, but you need
hyperlinks with a special formatting in the web version, then an F&R for REF
fields might be the road. There might be several steps you need to do to
format the doc.

Once you have worked out the manual workflow that gets you exactly what you
want, then see about converting it into a macro, or more than one macro.
You might, in fact, be able to attach the macro so that it intercepts the
Save As Web Page command, but that's the least part of what you need to do.

Links:

Creating a macro with no programming experience using the recorder
http://word.mvps.org/faqs/macrosvba/UsingRecorder.htm

How to modify a recorded macro
http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm

Word macro group for beginners:

http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=micros
oft.public.word.vba.beginners&lang=en&cr=US
 
G

Guest

Thanks for all the informational links, Daiya,

I did a little (very little) digging into the document source, and spotted
the numerous style definitions, and had a hunch that something might be done
using them.

I also saw the description of the "IF" statement, and hoped that there might
be some undocumented condition that could be tested that showed what the
current document format was going to be.

Obviously there is something that Word uses to alter the formatting of Table
of Contents entries depending on whether you are printing of saving to HTML.
This is automatic, and if this could be tested by an IF statement, it would
be a very simple matter to include or exclude portions of text based on that
value.

I believe I saw somewhere that others have suggested that Index entries be
automatically treated the same was as Table Of Contents entries when saving
to HTML. Then their page numbers would be removed and they would be
converted to hyperlinks.

Thanks again for the suggestions and the informational links.

Joe
 

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