• Can’t Get Word To Open (Access 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Can’t Get Word To Open (Access 2000)

    • This topic has 12 replies, 2 voices, and was last updated 21 years ago.
    Author
    Topic
    #406066

    I’ve created a button that opens a Word Mail Merge document. Except now it isn’t working and I don’t know what I did wrong. I keep getting the error “User-defined type not defined”. Does anyone have any idea? The following is the code that I have behind the button.

    Private Sub DoneSelectingbtn_Click()
    On Error GoTo Err_DoneSelectingbtn_Click

    DoCmd.GoToRecord , , acLast
    MergeIt

    Exit_DoneSelectingbtn_Click:
    Exit Sub

    Err_DoneSelectingbtn_Click:
    MsgBox Err.Description
    Resume Exit_DoneSelectingbtn_Click

    End Sub

    Function MergeIt()
    Dim objWord As Word.Document
    Set objWord = GetObject(“G:StudentLabels5163.doc”, “Word.Document”)
    ‘ Make Word visible.
    objWord.Application.Visible = True
    ‘ Set the mail merge data source as the Northwind database.
    objWord.MailMerge.OpenDataSource _
    Name:=”G:WorkingCopy.mdb”, _
    LinkToSource:=True, _
    Connection:=”QUERY Labels Query”
    ‘ Execute the mail merge.
    objWord.MailMerge.Destination = wdSendToNewDocument
    objWord.MailMerge.Execute
    End Function

    Viewing 1 reply thread
    Author
    Replies
    • #839197

      Have you set a reference to the Microsoft Word 9.0 Object Library in Tools | References… (in the Visual Basic Editor)?

      If that does not help, what is the item that is highlighted when you get the error?

      By the way, you must add Set objWord = Nothing at the end of MergeIt, to release the memory used by objWord.

      • #839243

        Hi Hans,

        Well it seems to work fine when I have the front and back end in the same place (G:MySchoolFeesHelp). But when I move the front end to my C:My FilesWorkingCopy.mdb, it doesn’t work right. It opens two more Access’s and it gives me a message box saying “The database has been placed in a state by user ‘Admin’ on machine ‘PALLISER-Jenn’ that prevents it from being opened or locked.” What does this mean?

        Function MergeIt()

        Dim objWord As Word.Document
        Set objWord = GetObject(“G:MySchoolFeesHelpStudentLabels5163.doc”, “Word.Document”)
        ‘ Make Word visible.
        objWord.Application.Visible = True
        ‘ Set the mail merge data source as the WorkingCopy database.
        objWord.MailMerge.OpenDataSource _
        Name:=”c:My FilesWorkingCopy.mdb”, _
        LinkToSource:=True, _
        Connection:=”QUERY Labels Query”
        ‘ Execute the mail merge.
        objWord.MailMerge.Destination = wdSendToNewDocument
        objWord.MailMerge.Execute
        Set objWord = Nothing

        End Function

        Here’s my code again–I changed the directories it was going to. It works fine when the .mdb is in the G:MySchoolFeesHelp folder along with the StudentLabels5163.doc, but it doesn’t work when I move the .mdb to C:My Files.

        • #839255

          Don’t know if it is related, but Word is known to try to open multiple copies of the database containing the source data if the database has an application name (that does not start with Microsoft Access.) You can set the application name for a database in Tools | Startup…

          Does your database have a non-blank application name? If so, does it help if you clear the name?

          • #839259

            When I go into Tools | Startup, I have a blank field under Application Title, and “none” under Display Form/Page. Is this how I should have it? Can’t I put “Switchboard1” in the Display Form/Page field to open up that switchboard when it starts up?

            • #839291

              Yes, you can select a form in the Display Form/Page dropdown to open that form automatically when the database is opened. A switchboard form is a good choice.

              I don’t know why you have problems with multiple instances of Access starting if the Application Title property is blank. – Oh, wait! After each design change to the database, you must close and reopen it before attempting to initiate a mail merge. When you change something in the design of a form, module etc., you lock the database exclusively, so Word cannot get at it. Closing and reopening the database should remedy that.

            • #839299

              Thanks Hans. Your awesome!

            • #839300

              Thanks Hans. Your awesome!

            • #839292

              Yes, you can select a form in the Display Form/Page dropdown to open that form automatically when the database is opened. A switchboard form is a good choice.

              I don’t know why you have problems with multiple instances of Access starting if the Application Title property is blank. – Oh, wait! After each design change to the database, you must close and reopen it before attempting to initiate a mail merge. When you change something in the design of a form, module etc., you lock the database exclusively, so Word cannot get at it. Closing and reopening the database should remedy that.

          • #839260

            When I go into Tools | Startup, I have a blank field under Application Title, and “none” under Display Form/Page. Is this how I should have it? Can’t I put “Switchboard1” in the Display Form/Page field to open up that switchboard when it starts up?

        • #839256

          Don’t know if it is related, but Word is known to try to open multiple copies of the database containing the source data if the database has an application name (that does not start with Microsoft Access.) You can set the application name for a database in Tools | Startup…

          Does your database have a non-blank application name? If so, does it help if you clear the name?

      • #839244

        Hi Hans,

        Well it seems to work fine when I have the front and back end in the same place (G:MySchoolFeesHelp). But when I move the front end to my C:My FilesWorkingCopy.mdb, it doesn’t work right. It opens two more Access’s and it gives me a message box saying “The database has been placed in a state by user ‘Admin’ on machine ‘PALLISER-Jenn’ that prevents it from being opened or locked.” What does this mean?

        Function MergeIt()

        Dim objWord As Word.Document
        Set objWord = GetObject(“G:MySchoolFeesHelpStudentLabels5163.doc”, “Word.Document”)
        ‘ Make Word visible.
        objWord.Application.Visible = True
        ‘ Set the mail merge data source as the WorkingCopy database.
        objWord.MailMerge.OpenDataSource _
        Name:=”c:My FilesWorkingCopy.mdb”, _
        LinkToSource:=True, _
        Connection:=”QUERY Labels Query”
        ‘ Execute the mail merge.
        objWord.MailMerge.Destination = wdSendToNewDocument
        objWord.MailMerge.Execute
        Set objWord = Nothing

        End Function

        Here’s my code again–I changed the directories it was going to. It works fine when the .mdb is in the G:MySchoolFeesHelp folder along with the StudentLabels5163.doc, but it doesn’t work when I move the .mdb to C:My Files.

    • #839198

      Have you set a reference to the Microsoft Word 9.0 Object Library in Tools | References… (in the Visual Basic Editor)?

      If that does not help, what is the item that is highlighted when you get the error?

      By the way, you must add Set objWord = Nothing at the end of MergeIt, to release the memory used by objWord.

    Viewing 1 reply thread
    Reply To: Reply #839300 in Can’t Get Word To Open (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel