Re: Bookmark with overwrite function?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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

"Jay Freedman" wrote:

> pvdalen wrote:
> > 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.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
>
>
>
.



Relevant Pages

  • Re: Bookmark with overwrite function?
    ... > text length between the bookmark and the data replacing the bookmark. ... I assume that the placeholder (what you're calling a bookmark, ... and separate the placeholder from that text with a tab character. ... out the physical width of text by counting its characters. ...
    (microsoft.public.word.vba.general)
  • Re: Identify page on which a bookmark is located
    ... The DocStart bookmark is identified ... going to the character before the first character in the ... an insertion point, but even if it is not I expect Previous can be ... Why use adjusted page argument - wdActiveEndAdjustedPageNumber? ...
    (microsoft.public.word.vba.general)
  • Re: Identify page on which a bookmark is located
    ... The DocStart bookmark is identified ... going to the character before the first character in the ... an insertion point, but even if it is not I expect Previous can be ... Why use adjusted page argument - wdActiveEndAdjustedPageNumber? ...
    (microsoft.public.word.vba.general)
  • Re: Identify page on which a bookmark is located
    ... I tried inserting another bookmark and finding the page as I did with the ... even though the last character was clearly on the second page. ... Dim rTmp As Range ... Set rTmp = ActiveDocument.Sections.Range ...
    (microsoft.public.word.vba.general)
  • Re: Identify page on which a bookmark is located
    ... previous character or next character and there are none at the beginning and ... "Collapse" produces nothing in VBA Help). ... for my GoTo Bookmark code. ... Collapses a range or selection to the starting or ending position. ...
    (microsoft.public.word.vba.general)