i am needing help with a command button that opens a word.docx?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • irishwoman0980
    New Member
    • Jan 2016
    • 1

    i am needing help with a command button that opens a word.docx?

    i am using access 2010 and needing it to open a word.docx so that the user can just add an address to it and be done. i have already created the template word.docx just need help linking the two together with a command button.
    haven't done code in a very long time and cant remember how to.
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    There are a few ways to do this...

    However, I think you'll end up with a modification of:

    home > topics > microsoft access / vba > insights > application automation


    Of course, for early binding (as shown in the two examples) you would set the library reference for MS Word instead of Outlook or Excel ;-)
    Once the code is written you can slightly alter it to use late binding to help bullet proof the code once you have things working correctly.

    Use the OpenDocuments Method of the Word object once created to open the document.

    While you have it open, you can also transfer information from the database to bookmarked fields in the document.

    As you mention that you have already done this in the past, let us know if you need more detailed help with this project.

    -Z

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      Another option should also be possible of using Shell() with just the name of the document. Assuming the PC is set to open Word for .DOCX files.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        For some reason I always seem forget about the shell()... IDKW
        :)

        In this case, I was thinking about being able to push the currently user-entered address from the database.
        > That's my story and I'm sticking to it! };-)
        (chuckle)

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32633

          #5
          There are usually many ways to crack a nut ;-)

          Comment

          • mbizup
            New Member
            • Jun 2015
            • 80

            #6
            A third nutcracker - behaves like double-clicking the file in it's folder if the application is on the computer (like the Shell command):

            Code:
            Application.FollowHyperlink "C:\Path\To\Your\File.anyextension"

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32633

              #7
              Originally posted by MBizup
              MBizup:
              A third nutcracker
              Third and best. It's what I should have suggested. The easiest and most straightforward approach.

              Comment

              • zmbd
                Recognized Expert Moderator Expert
                • Mar 2012
                • 5501

                #8
                Just keep in mind, how many times have we seen file-associations broken? :)

                Even with that, mbizup suggestion is the easiest to implement!

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32633

                  #9
                  Even if it were broken the solution would be to fix it rather than to change the approach to this question IMO. The Shell() approach would suffer from the same issue if it raised its head.

                  Comment

                  Working...