View Single Post
  #8   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Tom Tom is offline
external usenet poster
 
Posts: 61
Default Use DocVariable field to initiative numbering?

Greg,

Sub ScratchMacro()
Dim myRange As Range
Set myRange = ActiveDocument.Range
With myRange.Find
.Text = "XYZ"
.MatchWholeWord = True
While .Execute
myRange.Delete
myRange.InsertCaption Label:="Figure"
Wend
End With
End Sub


The macro code you wrote works much more quickly and powerfully, even
formatting the XYZ text in caption styles. Thanks!

Here's a little more background with what I'm trying to accomplish, and
why I was wondering about DocVariables. I'm a technical writer trying
to single source with Robohelp. Robohelp is an HTML-based application
that stores everything in discrete topics. It also outputs to Word.
When it outputs to Word, it strings together all the topics in one long
Word document.

The output to Word is problematic for two main reasons:

Captions and references to those captions -- Using the code and
techniques you and Peter explained, I can easily add captions to every
figure (by replacing XYZ with the captions). However, in the body of
the text, we often write "See Figure 1 below" or "See Figure 5 below."
How would I retain the "See Figure 5" part?

A similarly related problem is cross references. Let's say I want to
refer a reader to a topic on another page. In HTML, one simply says
"See Creating Documents" and makes it a link to the topic. However, in
the print output, "See Creating Documents" doesn't include any page
references. The topic could be on page 5 or 50. How could I set it up
so that the print output said "See Creating Documents on page 6" (where
page 6 is where the heading text appears that contains this topic)?

I have been told that it is possible to do this (cross references)
through a DocVariable. This is why I keep asking about it. If you have
a solution for cross references that works, it would make quite a few
technical writers happy. Any ideas?