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 / July 2007

Tip: Looking for answers? Try searching our database.

Userform InsertBefore Bookmark Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ronneilan@gmail.com - 02 Jul 2007 01:01 GMT
I have set up a userform which posts content to bookmarks in a
document using the InsertBefore method and then into Ref fields I have
placed through the document to pick up the content of the bookmarks.

I did this based on a MVP article I found which recommended I create
the bookmark with a space i.e. [ ] rather than |  .The space method
creates a problem throughout my document of having an extra space
after the word brought into the document from the form into the
bookmark. If I do it the other way my Refs don't pick up the text
which is dropped into the document as it is inserted before the
bookmark not actually in it.

Can any of you smart people help me out with a technique to get the
text from the userform into the bookmark so that there isn't any space
and the into the ref entries. Please.
Jay Freedman - 02 Jul 2007 01:11 GMT
There's another article on the MVP site that explains how to insert
text _in_ a bookmark:
http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm
It's a couple of steps instead of the single InsertBefore command, but
it eliminates that pesky space.

--
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.

>I have set up a userform which posts content to bookmarks in a
>document using the InsertBefore method and then into Ref fields I have
[quoted text clipped - 11 lines]
>text from the userform into the bookmark so that there isn't any space
>and the into the ref entries. Please.
Doug Robbins - Word MVP - 02 Jul 2007 02:46 GMT
An alternative to the use of a bookmark is to create document variables to
hold the data from the controls on the userform and then use DOCVARIABLE
fields in the document wherever you want the information to appear.

To create the document variables, you would use the following code in the
user form in place of that which inserts the information into the bookmarks

With ActiveDocument
   .Variables("varname1").Value = [controlname1].text
   etc.
   .Range.Fields.Update
End With

The corresponding document variable field for the above would be {
DOCVARIABLE varname1 }  You can have as many instances of the one document
variable field in the document as you wish.

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

>I have set up a userform which posts content to bookmarks in a
> document using the InsertBefore method and then into Ref fields I have
[quoted text clipped - 11 lines]
> text from the userform into the bookmark so that there isn't any space
> and the into the ref entries. Please.
 
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.