DPRG
DPRG List  



DPRG: Access 95 or 97

Subject: DPRG: Access 95 or 97
From: barry jordan barry_jordan at email.msn.com
Date: Tue Apr 7 18:07:41 CDT 1998

>Do you want a bit of code from Access to dump out the data to the word
>template?  Or are you looking for another stand alone?
>
>Do you have the template?
>
>Matt Minnis
>
>At 09:17 AM 4/7/98 -0500, you wrote:
>>Business not HOBBY
>>
>>My business database is Access 95.
>>I once had a nice control that dumped selected fields to a WORD template.
>>The programmer, I hired, used a VB call from a stand alone app.
>>Needless to say the app. is gone now .
>>
>>I'd be willing to pay someone, to straighten out my mess.
>>
>>Sorry for the commercial post.
>>However, someone could buy a new Botboard and/or sensors
>>for their new Robot with the extra money they could make.

This is  the event code for the comand button.
Basically, the code sends the chosen fields from a pick list of a record to
a word template.
As it is now (or was) the word templete has field markers.
Anything along these lines would be nice.
Not wanting a freebe.

Barry Jordan



Private Sub cmdPrintTemplate_Click()
On Error GoTo Err_cmdPrintTemplate_Click
    Dim db As DATABASE
    Dim rec As Recordset
    Dim count As Long
    Set db = CurrentDb
    Set rec = db.OpenRecordset("SELECT * FROM [Template/Field List]    WHERE
[Template] = '" & Forms![Order Form]![Template Combo] & "'", dbOpenSnapshot)

    Set wd = CreateObject("Word.Basic")
Continue_with_word:
    wd.AppActivate "Microsoft Word", 1
    wd.apphide
    wd.FileNew DLookup("Filename", "Template List", "[Template] = '" &
[Template Combo] & "'")
    DoCmd.OpenForm "Progress"
    count = 0
    Forms![Progress]![Progress Bar].MIN = 0
    Forms![Progress]![Progress Bar].MAX = DCount("Field", "[Template/Field
List]", "[Template] = '" & Forms![Order Form]![Template Combo] & "'")
    Forms![Progress].SetFocus
    Do Until rec.EOF
        wd.StartOfDocument
        wd.Editfind "_" & rec![Field] & "_"
        While wd.editfindfound()
            wd.INSERT "" & Me(rec![Field]) & ""
            wd.repeatfind
        Wend
        rec.MoveNext
        count = count + 1
        Forms![Progress]![Progress Bar].Value = count
    Loop
    db.Close
    DoCmd.Close acForm, "Progress"
    wd.StartOfDocument
    wd.appshow
Exit_cmdPrintTemplate_Click:
    Exit Sub
Err_cmdPrintTemplate_Click:
    If Err.Description = "Cannot activate application" Then
        myappid = Shell("C:\msoffice\winword\winword.exe", 6)
        Resume Continue_with_word
    Else
        MsgBox Err.Description
        Resume Exit_cmdPrintTemplate_Click
    End If
End Sub

------------------------------

More information about the DPRG mailing list

Copyright © 1984 - 2006 Dallas Personal Robotics Group. All rights reserved.
Website Design by NCC

For the latest robot news visit robots.net