Results 1 to 3 of 3
  1. #1
    jonnyh is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2016
    Posts
    1

    MS Word template with bookmarks

    Hi all



    Apologies if this is in the wrong category.

    My database has links to open MS Word templates and insert data from the db using bookmarks. A new document opens (.doc) everything works great.

    Problem is they don't work for any other users of the database, only me. Checking 'task manager' on other users PC shows Word open in the background (multiple versions if they have clicked the buttons more than once).

    Sample button code is as follows :

    ' open in Word
    Private Sub btnMG_Click()
    ' declare instance of Word
    Dim Wrd As New Word.Application
    Set Wrd = CreateObject("Word.Application")

    ' specify path and name to word doc
    Dim MergeDoc As String
    MergeDoc = Application.CurrentProject.Path
    MergeDoc = MergeDoc + "\DoNotOpenDbMG.docx"

    ' open doc template and make visible
    Wrd.Documents.Add MergeDoc
    Wrd.Visible = True

    ' replace bookmarks with current data
    With Wrd.ActiveDocument.Bookmarks
    .Item("bmFullName").Range.Text = IIf(IsNull(Forms!frmcase(![bmFullName])), "", Forms!frmcase(![bmFullName]))
    .Item("bmAgeCalculation").Range.Text = IIf(IsNull(Forms!frmcase(![bmAgeCalculation])), "", Forms!frmcase(![bmAgeCalculation]))
    .Item("bmOccupation").Range.Text = IIf(IsNull(Forms!frmcase(![bmOccupation])), "", Forms!frmcase(![bmOccupation]))
    End With
    End Sub


    Any obvious reasons why this setup shouldn't work for other users?

    any advice appreciated

    Thanks

    John

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I don't know the cause of your issue but I did notice something in your code:
    Code:
    Dim Wrd As New Word.Application
    Set Wrd = CreateObject("Word.Application")
    It probably works just fine and Access figures out what is needed but:
    Dim Wrd As New Word.Application
    Is what you would write for Early Binding (Word needs to be one of your references)
    Set Wrd = CreateObject("Word.Application")
    Is what you would write for Late Binding where Word is not one of your References...
    ...and this line would be preceded by:
    Dim Wrd As Object

    It is a fine point but I thought I'd point it out.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    The answer to your problem may be with the multiple instances of the document being open, as Rural Guy explained. I would address that issue first. Aside from that, we do not really understand what the symptoms are other than "it does not work with other users".

    When I look at the code, it seems this code was written several years ago. Perhaps Bookmarks are a little different nowadays and this collection recognizes different user profiles. I think this speculation is premature at this point, though.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Word template from Access reports
    By sunnyday in forum Reports
    Replies: 2
    Last Post: 12-22-2014, 09:40 PM
  2. Replies: 11
    Last Post: 01-26-2012, 09:28 AM
  3. Replies: 1
    Last Post: 03-18-2011, 03:22 PM
  4. Access Form to Word Bookmarks
    By markod in forum Forms
    Replies: 5
    Last Post: 12-27-2010, 05:18 PM
  5. font of word bookmarks
    By emilylu3 in forum Programming
    Replies: 1
    Last Post: 03-09-2006, 12:07 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums