Bookmark with overwrite function?

P

pvdalen

Hi all,

I've an Access db that writes to a Word document using bookmarks. I have
the template lined up just the way I want it; when the db writes info to the
template, the lines become offset by the difference in text length between
the bookmark and the data replacing the bookmark. For example, if
"McCracken" replaces "Last", the rest of the line is adjusted 5 places to the
right for the extra characters in "McCracken". If at all possible, I'd very
much like to have the system account for the extra spaces and delete them
during the process.

I was playing around with Word.Options.AutoFormatAsYouTypeInsertOvers and
Word.Options.Overwrite, but couldn't get them to work. Are one of these the
way to go? Or do I have to programmatically use the Len() function to
calcuate the difference in the text strings and then add/delete spaces? If
so, how exactly would that look?

I hope this made sense and thanks very much for your time and help.
Paul
 
J

Jay Freedman

pvdalen said:
Hi all,

I've an Access db that writes to a Word document using bookmarks. I
have the template lined up just the way I want it; when the db writes
info to the template, the lines become offset by the difference in
text length between the bookmark and the data replacing the bookmark.
For example, if "McCracken" replaces "Last", the rest of the line is
adjusted 5 places to the right for the extra characters in
"McCracken". If at all possible, I'd very much like to have the
system account for the extra spaces and delete them during the
process.

I was playing around with Word.Options.AutoFormatAsYouTypeInsertOvers
and Word.Options.Overwrite, but couldn't get them to work. Are one
of these the way to go? Or do I have to programmatically use the
Len() function to calcuate the difference in the text strings and
then add/delete spaces? If so, how exactly would that look?

I hope this made sense and thanks very much for your time and help.
Paul

Hi Paul,

It's not so much that it does or doesn't make sense, as that you're trying
to solve the wrong problem.

I assume that the placeholder (what you're calling a bookmark, but that's
something different in Word's jargon) is followed on the same line by other
text, and you're trying to make sure the other text doesn't move when you
make the replacement. There are two 'proper' ways to do that, and neither of
them involves spaces.

(1) Set a tab stop at the proper position for the beginning of the other
text, and separate the placeholder from that text with a tab character. As
long as the replacement's length is shorter than the distance up to the tab
stop, the other text won't move.

(2) Create a two-column table, inserting the placeholder in the first cell
and the other text in the second cell. If you turn off the table's borders,
and set Table > AutoFit to "Fixed column width", the replacement won't
affect the position.

The trouble with positioning by spaces is that, unless you format the text
in a nonproportional font such as Courier New or Lucida Sans Typewriter, you
can't guarantee alignment of the following text. You certainly can't figure
out the physical width of text by counting its characters.
 
P

pvdalen

Hey Jay,

Thanks very much for the response. This may sound stupid, because I'm
generally aware of issues regarding using spaces, but the only reason I was
attempting it this way was to have the remainder of the space between the
bookmark(s) and next column of text printed with an underline character.
I'll give your suggestion a shot.

Thanks very much!
Paul
 
R

Rodi

Yep, that's exactly what I found when I took you're earlier suggestion to use
that tab stop and everything worked like a charm!

Thanks again for all your help, Jay.
 

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