Access 2013 creates Word document

Posted on 2015-02-12
Last Modified: 2016-02-11
I've inherited an Access application that keeps track of requests for dog licenses, liquor licenses, etc. for my city.  Unfortunately, I don't have any Access experience.  While the application itself is running fine, the Word documents it produces have a watermark/background that needs to be updated.
The Access application has both a front-end and a back-end.  When I open them in Alt-F11 mode, I can see code, but don't see any references to where the initial Word document/template can be found.  

Where do I look for it?
Question by:ITHastings
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
LVL 58
ID: 40606863
Do the Alt/F11 to get into VBA, then look for .doc

The code may be part of a form.

If you don't find it there, then the template used may be a value stored in a table as a field.   Look through the table names for anything like "Settings", "init", etc.

LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40606886
if it is a template, you should look for .dot or .dotx or .dotm
LVL 26

Expert Comment

ID: 40606933
the Word documents it produces
So, it sounds like somewhere along the line, Word gets automated.
And probably as a mailmerge

Here's a snippet of how I get that started
        'open the mergedoc
        Dim oApp As Object
        Dim MlMrge As Object
        Set oApp = CreateObject(Class:="Word.Application")
        oApp.Visible = True
        'this will open a new document based on the path as a template.  Excellent
        'but it doesn't open it as a mail merge
        oApp.Documents.Add "c:\temp\Field Repair Welding Procedure Merge.doc"
        Set MlMrge = oApp.ActiveDocument.MailMerge
        With MlMrge
            'do the merge
            .OpenDataSource Name:="C:\temp\tblWeldProcData.xls", Connection:="DSN=Excel Files;DBQ=C:\temp\tblWeldProcData.xls;DriverId=1046;MaxBufferSize=2048;PageTimeout=5;", SQLStatement:="SELECT * FROM `tblWeldProcData`", SubType:=0 'wdMergeSubTypeOther
            .ViewMailMergeFieldCodes = 9999998 'wdToggle
            .Destination = 0 'wdSendToNewDocument
            .SuppressBlankLines = True
            With .DataSource
                .FirstRecord = 1 'wdDefaultFirstRecord
                .LastRecord = -16 'wdDefaultLastRecord
            End With
            .Execute (False)
        End With
        'save the merged doc
        oApp.ActiveDocument.SaveAs "c:\temp\RPR.doc"
        Dim Thedoc As Object
        'close the mergedoc
        For Each Thedoc In oApp.Documents
            If Thedoc.Name Like "document*" Then
                oApp.Documents(Thedoc.Name).Close False
            End If
        Next Thedoc
        oApp.Visible = True

Open in new window

Now, there's lots there, but the key bits are in bold
Set oApp = CreateObject(Class:="Word.Application")
Set MlMrge = oApp.ActiveDocument.MailMerge
For Each Thedoc In oApp.Documents

If you start looking for the bold bits in the entire VBA project, you should turn up the logic of how your app is working.

I've inherited an Access application...
Now, most developers think that storing files as attachments in tables is a lot like driving your car with your feet -- it can be done, but it's not a good idea.  Your predecessor may have done so to keep the app from being broken if someone moved/renamed/deleted/edited the source document, so it may be in a field in a table.  When you find the automation code driving Word, post it and we'll have a look.

Then the fun will begin.
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.


Author Comment

ID: 40608183
The backend only has tables, there's no code.  When I do a search on the front-end, I don't see any .doc* files.  I bring up the find tool, have it look for ".doc*" and search in "Current Project", it doesn't find anything.

What else can I look for, or where else should I be looking?

Author Comment

ID: 40608213
There's lots of occurrences of code (based on license type) like this, but I don't know enough about Access to know what I'm missing.

Private Sub cmdPrintReceipt_Click()
On Error GoTo Err_cmdPrintReceipt_Click

    Dim stDocName As String

    stDocName = "rptDogLicenseReceipt"
    DoCmd.OpenReport stDocName, acPreview

    Exit Sub

    MsgBox Err.Description
    Resume Exit_cmdPrintReceipt_Click
End Sub

Open in new window

LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40608323

di d you see my post at http:#a40606886 ?
LVL 26

Accepted Solution

Nick67 earned 500 total points
ID: 40608339
Perhaps we have a basic misunderstanding
'but I don't know enough about Access to know'
 stDocName = "rptDogLicenseReceipt"
    DoCmd.OpenReport stDocName, acPreview

This is code to open an MS Access report.
Reports can be previewed, and reports can be printed
Paper comes out of the printer

the Word documents it produces
that says something very different to an MS Access developer
Word documents are not MS Access reports; they can be printed and previewed but they are very different monsters.

Do you have a Word document or an MS Access report that you want to change?
That is the question!
Preview the document
Do you have a choice for Design View?
If you do, then you are dealing with an Access Report, and not a Word document
Is the dog license receipt one of the things that needs updating?
Because that is a report and has no relationship whatsoever with MS Word!

Author Comment

ID: 40608484
to Rey Obrero: Yes, I did a search through the code for all of the bolded strings, but found nothing.

Author Comment

ID: 40608497
to Nick67: Previewed the document and had a choice for Design View.  Thanks for your help.
LVL 26

Expert Comment

ID: 40608552
That's pretty terse!
So, you are dealing with a report
Were you able to get the changes you needed accomplished?

Author Closing Comment

ID: 40608871
Thanks for your patience.
LVL 26

Expert Comment

ID: 40608879
Glad to be of assistance!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use Windows Task Scheduler to print a Word document weekly so your printer ink won't dry out.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question