Page 1 of 4 123 ... LastLast
Results 1 to 15 of 46
  1. #1
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Repeat entry on Userform How? (Word 97)

    Thanks to the assistance of this forum I have successfully (well almost) created a userform for my Word Template.

    The problem that I have is that there are several times a persons Name and Id (for example) have to be entered on the form. When I insert the bookmark for the reference, I can only insert it once.

    I am sure I saw the answer to this somewhere here, but through a thorough "search" I couldn't find it.

    Kerry

  2. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Repeat entry on Userform How? (Word 97)

    Kerry,

    Each of your bookmarks will have to have a unique name, but you can assign them the same value from within your VBA code. If you need LastName to appear in 3 different places, that means 3 different bookmarks to take on the same value from a textbox for instance:

    ActiveDocument.Bookmarks("LastName1").Range.Text = txtLastName.Value
    ActiveDocument.Bookmarks("LastName2").Range.Text = txtLastName.Value
    ActiveDocument.Bookmarks("LastName3").Range.Text = txtLastName.Value

    An alternative to bookmarks is to use docvariable fieldcode references. An explanation appears in Microsoft Knowledge Base Article - 209227.

    Alan

  3. #3
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Repeat entry on Userform How? (Word 97)

    Thanks Alan. This works, but golly it is hard to work your way through the bookmarks. Is there a way to see the names of the bookmarks in the document other than "Insert Bookmark - Go To" ?

    Kerry

  4. #4
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Repeat entry on Userform How? (Word 97)

    Looks like you work's only just beginning. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> I agree that bookmarks are a pretty klunky feature - I guess it's because they've been carried through Word since its infancy without a major overhaul. There is some code here that might be of help . I seem to recall another bookmark manager addin or similar being mentioned somewhere, but the details elude me.

    All the bookmarks belong to the Bookmarks collection so they are readily accessed in VBA using a For Each Next block:

    For Each oBookmark In ActiveDocument.Bookmarks
    ....
    Next oBookmark

    You might be able to concoct something of your own here (if you're not sick of VBA yet) <img src=/S/grin.gif border=0 alt=grin width=15 height=15>.

    Alan

    Edited - Oh yes, and I forgot the bleedin' obvious. If you double click the status bar where it says Page .. Sec .. etc. it will open the Go To dialog directly. Might be a bit easier!

  5. #5
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Repeat entry on Userform How? (Word 97)

    Prime Consulting has a free add-in that puts a menu on your toolbar that shows all the bookmarks in your document. It's called bookpop.dot (or something similar <img src=/S/confused.gif border=0 alt=confused width=15 height=20>). You can find it at http://www.primeconsulting.com/freeware/.
    Hope this helps,

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Repeat entry on Userform How? (Word 97)

    They do? No way! I posted one here in August 2002, <post#=165392>post 165392</post#>. I wonder if we ended up with similar designs?

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Repeat entry on Userform How? (Word 97)

    I hadn't remembered your post & forgot that I could search <img src=/S/grin.gif border=0 alt=grin width=15 height=15>. The Prime Consulting template is locked & password protected, naturally, so I can't tell what their code is. But I'll bet it's similar.

  8. #8
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Repeat entry on Userform How? (Word 97)

    I should have asked why you need to "work your way" through the bookmarks. If you need access to any of their current values, you can just reshow the userform. If it's an existing doc that's being opened for edit, you can use the form's initialize event Sub UserForm_Initialize() to collect the existing bookmark values and fill the userform. I've done this often using document variables, but I think the principle would be the same for bookmarks.

    Alan

  9. #9
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Bookmark bug???

    I am trying to place bookmarks in the document to refer to in my code. It is particularly tricky when there is more than one instance of the same information. I am using your code method to do this.

    I have now discovered that bookmarks are CRAP! There has to be a bug in them. Now I am looking for information of Word97BookmarkBugs.

    I have found that when I open a new document and chose to clear or cancel - the contents of the option group stays with the document template and when I open a new blank version I get the contents of the option group twice and so on.

    HELP! I thought this would be easy!!! Oh why did I think that.

    By the way I downloaded the Prime Bookmark Popup - which works well.

    Kerry

  10. #10
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Bookmark bug???

    Is it possible to post your template (i.e., in a ZIP archive)? I'm having difficulty understanding what it does. Here's my take: You have a userform that gathers information, then you want that information to be inserted in several places in the document. Assuming this is correct you have two choices:

    (1) Store each element of information you've gathered in a single place, and use field codes to cause them to display in multiple places. Example: Save the "Name" into a document variable or custom document property and insert a DOCVARIABLE or DOCPROPERTY field wherever you want the information to appear.

    (2) Manually (using code, of course) type each element of information into the document at various marked locations. Example: Add a bookmark to every place where you want the information inserted, and then type the text there.

    Each approach has its benefits and problems, but from the problems you're running into, I'm not sure I understand how you're tackling this.

  11. #11
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Tedious bookmarks

    I probably shouldnt be posting this form on here, but I am desparate for some advice on making it less tedious to make lots of entries of the same information. I have 5 of them to make, so any improvement will be a great timesaver.

    I think I have overcome the option group problem, but take a look at the code and you may see something obvious I cant.

    Kerry
    Attached Files Attached Files

  12. #12
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tedious bookmarks

    Kerry,

    I can't see any "problems" as such with your code, but the big question is whether it works the way you'd like it to. I guess it was modelled on Martin Green's example I mentioned. Bearing in mind that this was an introductory/ instructional tutorial, his template does have some (IMO severe) limitations.

    Firstly, it's "one chance only" to get the details correct when a new doc is created. There's no (easy) opportunity to review the document then bring up the form again to make changes. Secondly, there's also no opportunity to edit an existing document via the form. The way I've done this sort of thing (apart from a preference for document variables over bookmarks) is to

    <UL><LI>Initialize all bookmarks to empty strings (new document only, via AutoNew() procedure).
    <LI>Fill (seed) the userform with the bookmark values (be they existing text or empty strings - you may have problems with Null values doing this).
    <LI>Show the userform, let the user play.
    <LI>Have the Cancel button simply hide the userform rather than unload it and close the document. The OK button commits the changes to the document, whereas the Cancel doesn't
    <LI>When the userform is made visible again, reseed it with the bookmark values from the document, using the same code procedure as before.[/list]You'll, of course, need a way for the user to reshow the userform. If you don't like the commandbar button idea, there's simple macrocode you can make available to the user by placing it in a "normal" module (other than the userform module):

    Sub ShowBreachForm()
    frmBreachFailureToReport.Show
    End Sub

    You could give this a shortcut key or use a MacroButton fieldcode to draw the user to its existence.

    These are a couple of ways to make the whole show more flexible. I personally prefer the use of document variables and their field codes to bookmarks, but the latter should still work OK in this context. Another potential advantage with field codes is that they can be unlinked, converting the values to regular text, and setting the document in stone, as it were. Further, they can't be altered at the user interface like bookmarks can potentially be - this can only be done through VBA.

    You can also repeat the same document variable fieldcode throughout the document, without having to fiddle with unique names. For instance,
    { DOCVARIABLE "CCC" }

    could appear several times, and the only line of VB you'd need is:
    ActiveDocument.Variables("CCC").Value = txtCCC.Value

    When refreshing the form values, it's just the reverse:
    txtCCC.Value = ActiveDocument.Variables("CCC").Value

    But keep on it - you're nearly there! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Alan

  13. #13
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Bookmark bug???

    Hi Jefferson

    Just for interest/ reference, what do you see as the relative merits/ problems of using docvars and bookmarks?

    Alan

  14. #14
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tedious bookmarks

    Hi Alan:
    I didn't see a Martin Green example referred to. Do you have URL? <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

  15. #15
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tedious bookmarks

    Hi Phil

    I was referring to this URL, which I recommended in a different thread but associated with the same topic.
    See <!post=Userform - Example Required (Word 97),324104>Userform - Example Required (Word 97)<!/post> for details.

    Alan

Page 1 of 4 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •