Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2004

    Unanswered: MS Word with Access


    I'm wondering if it is possible to have a button in a form which opens some file with MS Word. If it is how could I do it?

    And how to pass on the value of a text box of a form to a MS Word's document?

    Thanks for any suggestions,

  2. #2
    Join Date
    Feb 2003
    The short answer is yes it can be done.
    I will have to search for my code because it has been a couple of years since I had the same need.

  3. #3
    Join Date
    Apr 2004
    Sydney Australia
    My data base has that by the dozens. This is Access 95 running on Windoows XP

    Here is the first part of one of them

    Private Sub Label286_Click()

    Const MSTB_MSWORD = 300&

    Application.Run "utility.util_StartMSToolbarApp", MSTB_MSWORD

    Dim docName As Object
    Set docName = CreateObject("Word.Basic")

    docName.FileOpen "c:\Letters\FSG.doc"

    DoCmd.RunMacro "Macro11Street", , ""
    docName.EditGoTo "a3"

    DoCmd.RunMacro "Macro11Suburb", , ""
    docName.EditGoTo "a4"

    End Sub

    The macros Macro11Street and Macro11Suburb are just a GoToControl and Then Copy.

    In the bit below

    docName.EditGoTo "a4"

    "a4" is a Bookmark in Word

    Then if you wish

    docName.FileClose (2)

    That prints the doc and closes it without saving.

    I am current battling to reproduce a similar thing for Excel.

    Last edited by Mike375; 05-18-04 at 10:48.

  4. #4
    Join Date
    Mar 2004
    Could you tell me what do you exactly have in that Macro's?? I'm a completely beginner with that.

    I would be grateful,

  5. #5
    Join Date
    Apr 2004
    Sydney Australia
    What version of Access do you have as there are some changes with what macro actions are called. The action in question is DoMenuItem but it is called something different in later versions of Access. I think from after Access 97.

    Have you made any macros before? That way we will know where to start.

    The following Data Base forum

    has a form on macros and I am sure someone there will be able to tell you what the later versions of


    are called.

    On the early versions of Access the DoMenuItem allows you to select all of the actions that you can use from the toolbar from File, Edit and so on.


  6. #6
    Join Date
    Mar 2004
    Nashville, TN
    If you have Access XP 2002 the code will be slightly different so I may have to paste some code on here... as a matter of fact I will go ahead and post my code on here. It actually doesnt put the information in a certain spot because I wasnt using bookmarks, as well as it creates a new word document not a predefined one though that isnt hard to change. Just compare mine with Mike375 and you should be able to go from there.

    Option Compare Database
    Dim appWD As Word.Application
    Dim docWD As Word.Document
    Public Function cstInfo()
        Dim frmCurrForm As Form
        Dim strPartID, strDescription, strTmpPath As String
        Dim intPounds As Integer
        Dim curTotalCost As Currency
        Set frmCurrForm = Screen.ActiveForm
        'Set strTmpPath = "c:\Documents and Settings\Jarvis\My Documents\"
        'strPartID = frmCurrForm.PartID
        With frmCurrForm
            strPartID = .PartID
            strDescription = .Description
            intPounds = .Pounds
            curTotalCost = .TotalCost
        '    objPicture = .Picture
        End With
        Set appWD = CreateObject("Word.Application")
        appWD.Visible = True
        Set docWD = appWD.Documents.Add
        appWD.Selection.TypeText (strPartID & vbCrLf & strDescription & vbCrLf & intPounds & vbCrLf & curTotalCost)
        'appWD.Templates = strTmpPath & ""
    End Function
    Hope this helps you some.

    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting by Patriot Designs

  7. #7
    Join Date
    Jan 2004
    California, USA

    Smile Re: MS Word with Access

    I have an alternate solution that involves rich text, if you would like to take a look. The attached sample is developed in A2K and works fine when I'm at work in a Windows XP OS; but has some difficulties on my home computer in a Window Me OS. Never the less, it works. It contains 4 tabs on a tabcontrol and each tab has a rich text field. Enter data in any of the rich text fields and click the save icon. Then with the cursor in the rich text field, do a right click and my "rftZoomEditor" pops up with a number of edit buttons that are similar to MS Word. You should be able to edit and format your text. To place images, just drag them from their source and drop them in the rich text field. You can also cut and paste them. I would have left images in this sample, but the file size is to large to post in a forum. Let me know how it works for you. I'm still looking for a spell checker that works in rich text.

    Attached Files Attached Files
    Last edited by PC User; 08-03-04 at 22:54.

Posting Permissions

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