Re: Error 5101 Bookmark Does Not Exist - Word VB Template - Help!!

From: Jonathan West (jwest_at_mvps.org)
Date: 07/23/04

  • Next message: Chad DeMeyer: "Re: Copy and paste top of form to new page"
    Date: Fri, 23 Jul 2004 17:46:00 +0100
    
    

    Hi Clint,

    If the error is that the bookmark is missing, find out which bookmark the
    code is trying to manipulate, and then see if it actually exists. probably
    what has happened is that you have moved the code over, but not ensured that
    the destination template has the same set of bookmarks.

    -- 
    Regards
    Jonathan West - Word MVP
    www.intelligentdocuments.co.uk
    Please reply to the newsgroup
    "Clint Wagner" <cawagner@indiana.edu> wrote in message
    news:eG4PF2$bEHA.796@TK2MSFTNGP09.phx.gbl...
    > Hello, [please let me know if this is wrong group]
    > I have searched for the problem that I am having and I have found
    > similar references, but the fixes are correcting the minor issue that I
    > am having.
    >
    > Problem:  Getting Error 5101 after hitting "OK" on user input form.
    > Form Description:  It's a basic fax UserForm (Name, Pages, Destination,
    > Fax No, Company, etc) that passes the characters from the UserForm onto
    > designated positions in the Word document.
    >
    > In my first creation of this template, everything works fine after
    > filling out the form.  The text and #'s are passed onto the document
    > perfectly.  However, I found that I started getting Error 5101 when I
    > copied the code from my original project/templated for the creation of
    > my second project/template which is almost identical but with a differnt
    > caption for the UserForm .  I am also noticing that the UserForm for the
    > second document (ProjectTemplate as it refers in VB pane) is referencing
    > the UserForm from my orignial template.  I can tell this b/c each
    > UserForm has a different caption.
    >
    > Let me know if you have any ideas or suggestions: (Below is pasted code)
    >
    >
    >
    > Private Sub PB_Cancel_Click()
    >      On Error GoTo PB_Cancel_Click_Error
    >      Application.ScreenUpdating = False
    >      Selection.GoTo What:=wdGoToBookmark, Name:="DocumentStart"
    >      Application.ScreenUpdating = True
    >      Unload Frm_Dialog
    >      Exit Sub
    > PB_Cancel_Click_Error:
    >      MsgBox "Error Number " & Err.Number & Chr$(13) & Chr$(10) &
    > Err.Description, vbOKOnly + vbCritical,
    > ActiveDocument.BuiltInDocumentProperties("Company") & " " &
    > ActiveDocument.BuiltInDocumentProperties("Title")
    >      Application.ScreenUpdating = True
    >      Unload Frm_Dialog
    > End Sub
    >
    > Private Sub PB_OK_Click()
    >      On Error GoTo PB_OK_Click_Error
    >      Application.ScreenUpdating = False
    >      'Insert To Field.
    >      Selection.GoTo What:=wdGoToBookmark, Name:="DocumentStart"
    >      Selection.InsertBefore Text:=TB_To.Text
    >      'Insert Destination.
    >      Selection.GoTo What:=wdGoToBookmark, Name:="Destination"
    >      Selection.InsertBefore Text:=TB_Destination.Text
    >      'Insert Company.
    >      Selection.GoTo What:=wdGoToBookmark, Name:="Company"
    >      Selection.InsertBefore Text:=TB_Company.Text
    >      'Insert Pages.
    >      Selection.GoTo What:=wdGoToBookmark, Name:="Pages"
    >      Selection.InsertBefore Text:=TB_Pages.Text
    >      'Insert From Field.
    >      Selection.GoTo What:=wdGoToBookmark, Name:="From"
    >      Selection.InsertBefore Text:=TB_From.Text
    >      'Insert Sender Field.
    >      Selection.GoTo What:=wdGoToBookmark, Name:="Sender"
    >      Selection.InsertBefore Text:=TB_Sender.Text
    >      'Insert Date.
    >      Selection.GoTo What:=wdGoToBookmark, Name:="Date"
    >      Selection.InsertBefore Text:=TB_Date.Text
    >      'Insert Subject.
    >      Selection.GoTo What:=wdGoToBookmark, Name:="Subject"
    >      Selection.InsertBefore Text:=TB_Subject.Text
    >      '*Position insertion point for user.
    >      Selection.GoTo What:=wdGoToBookmark, Name:="DocumentEnd"
    >      Application.ScreenUpdating = True
    >      Unload Frm_Dialog
    >      Exit Sub
    > PB_OK_Click_Error:
    >      MsgBox "Error Number " & Err.Number & Chr$(13) & Chr$(10) &
    > Err.Description, vbOKOnly + vbCritical,
    > ActiveDocument.BuiltInDocumentProperties("Company") & " " &
    > ActiveDocument.BuiltInDocumentProperties("Title")
    >      Application.ScreenUpdating = True
    >      Unload Frm_Dialog
    > End Sub
    >
    >
    > Private Sub UserForm_Activate()
    >      Frm_Dialog.Caption =
    > ActiveDocument.BuiltInDocumentProperties("Company") & " - " &
    > ActiveDocument.BuiltInDocumentProperties("Title")
    >      TB_From = Application.UserName
    >      TB_Date = Format(Date, "MMMM dd, yyyy")
    > End Sub
    

  • Next message: Chad DeMeyer: "Re: Copy and paste top of form to new page"

    Relevant Pages

    • Re: Which button was pressed?
      ... form until you unload it, but unless it is a big form with lots of code, or ... When do I unload the userform? ... > Sub ChooseCohorts() ... >>Bob Phillips ...
      (microsoft.public.excel.programming)
    • Re: Cross Referencing bookmarks created by a Userform
      ... "Suzanne S. Barnhill" wrote: ... Private Sub CommandButton1_Click ... I've created a letter which pops up a Userform which the user completes ... document (stating that it is Reference Type: Bookmark and Insert ...
      (microsoft.public.word.docmanagement)
    • Re: Initialize Event fails
      ... > Public Sub FormStart() ... > What I actually did was run the UserForm from the VBA IDE. ... Pressing the X and using Unload Me ... using object variables as inherently more reliable and controllable. ...
      (microsoft.public.word.vba.userforms)
    • Re: Cross Referencing bookmarks created by a Userform
      ... am not rolling my eyes at all). ... Private Sub CommandButton1_Click ... I've created a letter which pops up a Userform which the user completes ... document (stating that it is Reference Type: Bookmark and Insert ...
      (microsoft.public.word.docmanagement)
    • Re: passing values from one for to another
      ... > I created a userform called frmTEST with a textbox control ... > End Sub ... about - using custom methods to open the form and unload it, ... Set Myform = New Form1 ...
      (microsoft.public.vb.general.discussion)