Results 1 to 2 of 2
  1. #1
    BrianFawcett is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2010
    Posts
    7

    Issue with VBA Code Using Bookmarks in Word to populate from Access Form

    I have a database where an administrator enters orders. For certain products, a warning pop-ups. Right now the user can open a Word doc of the warning, and I would like it to be populate with two fields from the Access Form they are using.

    I am getting a Comile error:Invalid qualifier. Below is my code, can someone help me out.

    Case "DS Inserters"
    Msg = "INSERTER CONFIGURATION REQUIRED!!!" & vbCrLf & "" & vbCrLf & "This Order includes a DS Series Equipment and must be sent the contacts below for Configuration Approval" & vbCrLf & "" & vbCrLf & "DS 62 - DS 75 do not require approvals is ok to process" & vbCrLf & "" & vbCrLf & "DS 80 - DS 86 must be sent to MARK NAITO" & vbCrLf & "" & vbCrLf & "DS 100 - DS 1200 must be sent to RICK DEJAGGER" & vbCrLf & "" & vbCrLf & "Would you like to Print this message?" ' Define message.
    Style = vbYesNo + vbExclamation + vbDefaultButton1 ' Define buttons.
    Title = "DS SERIES INSERTER - CONFIGURATION REQUIRED!!!" ' Define title.
    Response = MsgBox(Msg, Style, Title)

    If Response = vbYes Then ' User chose Yes.
    'start print
    Dim MailDoc As String
    Dim oApp1 As Object
    'Path to the word document
    MailDoc = "I:\DeptShare\C\Customer Service\Confidential\Custcare\2 - Reporting\New DDC Order Tracker\Order Tracker Documents\DS EQUIPMENT INSERTER CONFIGURATION REQUIRED.docx"
    If Dir(MailDoc) = "" Then
    MsgBox "Document not found."
    Else
    'Create an instance of MS Outlook
    Set oApp1 = CreateObject(Class:="Word.Application")
    oApp1.Visible = True


    'Open the Document
    oApp1.Documents.Open filename:=MailDoc

    With MailDoc.Bookmarks
    .Item("InHouseRef").Range.Text = Nz(Me.InHouseRef)
    .Item("Name").Range.Text = Nz(Me.Name)

    End With

    End If
    'stop print
    Exit Sub ' Perform some action.

    Else ' User chose No.
    DoCmd.Close acForm, "New Entry Form"
    End If

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Brian,

    I don't know if this will help but I did find a post on Tektips that did some Word/Access
    manipulations.
    Here is the link and the code is at the end of the posts.

    http://www.tek-tips.com/viewthread.c...1249866&page=1

    Hope it is useful to you.


    I did note in your code that there is a comment that's a little confusing.
    'Create an instance of MS Outlook
    Set oApp1 = CreateObject(Class:="Word.Application")

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

Similar Threads

  1. Access Form to Word Bookmarks
    By markod in forum Forms
    Replies: 5
    Last Post: 12-27-2010, 05:18 PM
  2. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 AM
  3. Word document INTO Access form
    By jonathonhicks in forum Forms
    Replies: 0
    Last Post: 04-30-2007, 05:59 PM
  4. Replies: 1
    Last Post: 09-06-2006, 11:48 AM
  5. font of word bookmarks
    By emilylu3 in forum Programming
    Replies: 1
    Last Post: 03-09-2006, 12:07 PM

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