By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,454 Members | 2,633 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,454 IT Pros & Developers. It's quick & easy.

Integrating WordMerge module in MS Access

P: n/a
Dear list,

I have an existing MsAccess database application. And integrated a nice
module for WordMerge into this. -Works fine.

Now I want to finetune this, so it does the merge with 1 click instead
of 2-3 forms in between.
I could study and search untill I know how to do this myself.

But if there is someone around willing to hep at a reasonable fee,
he/she is welcome.

You may contact me here: h.e.weenink(AT)aristo-webdesign.nl.

Jan 3 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Aristo WebDesign wrote:
Dear list,

I have an existing MsAccess database application. And integrated a nice
module for WordMerge into this. -Works fine.

Now I want to finetune this, so it does the merge with 1 click instead
of 2-3 forms in between.
I could study and search untill I know how to do this myself.

But if there is someone around willing to hep at a reasonable fee,
he/she is welcome.

You may contact me here: h.e.weenink(AT)aristo-webdesign.nl.
Did you look at Albert Kallal's "Super Easy Word Merge"? As he says,
it doesn't get much easier. Albert's example has a form that does all
the stuff for you. I think you maybe have to change a line of code.
maybe.

http://www.members.shaw.ca/AlbertKal...rge/index.html

Jan 3 '07 #2

P: n/a
To call the function:

MergeQuery "qryName", "C:\folder\MyWord.doc"

This will print one "Fill-in-form" or many form letters, depending on your
needs.

To call the function and add a photo to the Word Doc (only one at a time):

MergeQuery "qryName", "C:\folder\MyWord.doc", _
"C:\photoFolder\JimWebb.jpg", 360, 44, 140, 178

If you place a <ffin the document, a Form Field will be created (in case
there are fields to still be filled in by the user).

Filling in checkboxes is complicated - much easier to show than explain -
but essentially you need to use if/then in the mergefield, as in:

{IF {MERGEFIELD "is_felon"}="0" "O" "@"} Where the "O" is an empty checkbox
from wingdings and the "@" is a filled checkbox from wingdings.

Of course, this is not typed in text, but is created using the "Toggle Field
Codes" context menu choice in Word.

'************************************************* ******
' Much of this code section was adapted from code
' created by Albert D. Kallal. It has been adapted for this specific
' purpose. For why this method is preferable, and how to put it into your
' a application, please go to the original source at
' http:/www.members.shaw.ca/AlbertKallal/wordmerge/page2.html
'************************************************* ******
' The file, merge.txt, will be created automatically.
'
'************************************************* ******
Public Function MergeQuery(queryName As String, _
docName As String, Optional photoPath = "", _
Optional pLeft = 0, Optional pTop = 0, _
Optional pWidth = 0, Optional pHeight = 0) As
Boolean
On Error GoTo handle_error
MergeQuery = False

Dim i As Integer
Dim mWord As Object
Dim mDoc As Object
Set mWord = CreateObject("Word.Application")

DoCmd.Hourglass True
DoCmd.TransferText acExportDelim, , queryName, _
"C:\folder\merge.txt", True
With mWord
Set mDoc = .Documents.Open(docName)
.ActiveDocument.MailMerge.MainDocumentType = 0
If .ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
.ActiveDocument.Unprotect
End If

.ActiveDocument.MailMerge.OpenDataSource Name:="C:\folder\merge.txt", _
AddToRecentFiles:=False, Format:=0, Connection:="", _
SQLStatement:="", SQLStatement1:=""
.ActiveDocument.MailMerge.Execute

If Len(photoPath) 0 Then
On Error Resume Next
.ActiveDocument.Shapes.AddPicture photoPath, False, _
True, 360, 44, 140, 178
On Error GoTo handle_error
End If

.Application.Selection.Find.ClearFormatting
Do While .Application.Selection.Find.Execute(FindText:="<ff >", _
Wrap:=wdFindContinue, Forward:=True) = True
.ActiveDocument.FormFields.Add Range:=.Application.Selection.Range, _
Type:=wdFieldFormTextInput
Loop

If .ActiveDocument.ProtectionType = wdNoProtection Then
.ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True, Password:=""
End If
.Application.Visible = True

mDoc.Close
End With
MergeQuery = True
exit_point:
Set mWord = Nothing
Set mDoc = Nothing
DoCmd.Hourglass False
Exit Function
handle_error:
MsgBox Err.Description
GoTo exit_point
End Function
--
Darryl Kerkeslager
"Aristo WebDesign" <h.*********@aristo-webdesign.nlwrote
I have an existing MsAccess database application. And integrated a nice
module for WordMerge into this. -Works fine.

Now I want to finetune this, so it does the merge with 1 click

Jan 3 '07 #3

P: n/a
Thank you Darryl and Piet

Arno Raaijmakers (also known in this group) allready jumped and solved
the problem.
So this thread maybe closed.

BTW. The module was the module of Albert Kallal. Great work he did!

Regards, Eef

Jan 4 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.