Link to home
Start Free TrialLog in
Avatar of ITHastings
ITHastingsFlag for United States of America

asked on

Access 2013 creates Word document

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?
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

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.

Jim.
if it is a template, you should look for .dot or .dotx or .dotm
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
oApp.ActiveDocument.SaveAs
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.
Avatar of ITHastings

ASKER

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?
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_cmdPrintReceipt_Click:
    Exit Sub

Err_cmdPrintReceipt_Click:
    MsgBox Err.Description
    Resume Exit_cmdPrintReceipt_Click
End Sub

Open in new window

@ITHastings

di d you see my post at http:#a40606886 ?
ASKER CERTIFIED SOLUTION
Avatar of Nick67
Nick67
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
to Rey Obrero: Yes, I did a search through the code for all of the bolded strings, but found nothing.
to Nick67: Previewed the document and had a choice for Design View.  Thanks for your help.
@ITHastings.
That's pretty terse!
So, you are dealing with a report
Were you able to get the changes you needed accomplished?
Thanks for your patience.
Glad to be of assistance!