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 / March 2008

Tip: Looking for answers? Try searching our database.

Userforms -> Bookmarks Vs Doc Variables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Shane - 12 Mar 2008 21:28 GMT
Hi.

I've notice a number of times the recommendation to use Doc Variable
instead of Bookmarks to hold data entered via a Userform.  I've not
noticed any explanation as to why.  Just a simple recommendation.

While I have my own theory as to why Doc Variables may be a better way
to go, I tend to go with the bookmark method.  Why?  It works for me
and has done in all the project I've worked on (so far).

In the interests of educating myself and possibly others, I'd like to
ask the assembled masses their thoughts.

So...why one method over the other?

Thanks in advance.
Jay Freedman - 12 Mar 2008 22:43 GMT
> Hi.
>
[quoted text clipped - 12 lines]
>
> Thanks in advance.

Bookmarks are "fragile" -- most people don't turn on the display of
bookmarks, and it's very easy to delete a bookmark while editing text. If
your userform code simply assumes the bookmark exists, it will throw an
error when it tries to insert text at a nonexistent bookmark ("The requested
member of the collection does not exist"). If you have to do a thorough job
of checking for bookmarks, and maybe recreating missing ones, you have quite
a lot of work to do.

When the userform code sets or modifies a document variable, the code
involved is much simpler. In the document, the DocVariable field can be seen
(assuming there's some default value of the variable when the document is
created from the template) so it's less likely to be deleted by mistake. If
someone does delete the field, the only consequence is that the variable's
value doesn't appear where it should.

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.

Doug Robbins - Word MVP - 12 Mar 2008 23:01 GMT
Another advantage is that data can be retrieved (more reliably) from a
document variable than from a bookmark as the data may be inserted before
the bookmark and not actually be contained within the bookmark.

On the other hand, there are times when a bookmark can be used where a
document variable and DocVariable field does not work so well - inserting
items from a multiline textbox into the cell of a table is one.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hi.
>
[quoted text clipped - 12 lines]
>
> Thanks in advance.
Jonathan West - 13 Mar 2008 02:02 GMT
> Hi.
>
[quoted text clipped - 12 lines]
>
> Thanks in advance.

One further advantage is that with a single docvariable (or docproperty for
that matter) you can have multiple DOCVARIABLE or DOCPROPERTY fields all
pointing to the same property, if you need the same data to be displayed in
different places (e.g. in odd and even page headers)

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

 
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.