Open Microsoft Word Document in Access

How would I go about setting up a a button in Access 2013 to open a certain word document and insert in information from access? Example is we have a label printer so I was going to set it up to get mailing information and print to that printer which I have done but sometimes we need to edit the mailing address so I would like to open a blank word document and edit from there unless there is a better solution. Thanks
Brandon GarnettAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
Try this for a start

Dim objWord As Object
Dim objDoc As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add(ThePathToTheDocumentYourAreGoingToUseAsTemplate)
With objDoc
.formfields(NameOfTheFormField).result = TheValueYouWantToPass

End With
objWord.Selection.WholeStory
    objWord.Selection.Fields.Unlink
objDoc.PrintOut
    Set objDoc = Nothing
    Set objWord = Nothing

Open in new window

In order for this to work you need to use Form Fields
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fabrice LambertFabrice LambertCommented:
Hi,

easy enough:
public sub button1_onClick()
On Error Goto Error
    Dim app As Object    '// Word.Application
    Dim doc As Object    '// Word.Document

    Set app = createObject("Word.Document")
    set doc = app.Documents.Add    '// create an empty document
    app.Visible = True

    '// manipulate your document here

    doc.SaveAs2 "c:\.............."
    set doc = Nothing
    app.Quit False
    set app = Nothing
Exit Sub
Error:
    If Not(doc Is Nothing) Then
        doc.Close False
        Set doc = Nothing
    End If
    If Not(app Is Nothing) Then
        app.Quit False
        Set app = Nothing
    End If
End Sub

Open in new window

Note:
Do not close the document neither exit the application if you want to keep it open, just set the objects to Nothing.
0
Brandon GarnettAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.