Adam Borrie
AdamB at peabody.org.uk
Mon Jan 10 04:31:30 CST 2005
Dear All
The following piece of code used to execute fine in Access 97 but following
an upgrade to Access 2003 the code does not seem to work (and please ignore
the commented out sections - I'm a messy coder!). It always seems to fall
over at the wdSendToNewDocument statement and jump immediately to end of the
function. My hunch is that is that is something to do with the revised
references to the Word library.
Can any of you offer any suggestions or tell me where I should be looking to
solve the problem. Or if you have another piece of code that does the same
function then that would be great to.
Many thanks
Code:
DoCmd.OutputTo A_QUERY, QueryName, A_FORMATRTF, sDataDir & Source, False
'DoCmd.TransferText acExportMerge, , QueryName, sDataDir & Source
strTemplate = LetterName
'On Error Resume Next
On Error GoTo Label1
' Set appWord = GetObject(, "Word.Application")
' If Err <> 0 Then
' Set appWord = CreateObject("Word.Application")
' WordWasNotRunning = True
' End If
'appWord.Documents.Open Chr(34) &
J:\marketingSystem\Letters\Homebuy\Homebuy Tenancy Surrender
Form.doc & Chr(34)
appWord.Documents.Open Chr(34) & sFEndDir & strTemplate
& Chr(34)
'appWord.ActiveDocument.MailMerge.OpenDataSource
Name:=sFEndDir & "qMergeLetter.rtf", _
' linktosource:=True ', Connection:="Query
qMergeLetter"
With appWord.ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute True
End With
strTemplate = sFEndDir & strTemplate & ".doc"
appWord.Documents(strTemplate).close
SaveChanges:=wdDoNotSaveChanges
If appWord.Visible = False Then
appWord.Visible = True
appWord.WindowState = wdWindowStateMaximize
End If
Exit Function
Label1:
Msgbox Error
Adam Borrie
Systems Developer
direct line 020 7021 4439
Peabody Trust
45 Westminster Bridge Road
London SE1 7JB
#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared
by MailMarshal
For more information please visit www.marshalsoftware.com
#####################################################################################
This email and any files transmitted with it are confidential and intended
solely for the use of the individual to whom it is addressed. Any views or
opinions presented are solely those of the author and do not necessarily
represent those of the Peabody Trust.
If you are not the intended recipient, be advised that you have received this
email in error and that any use, dissemination, forwarding, printing, or
copying of this email is strictly prohibited. If you have received this email
in error please notify the Peabody Trust IT Help Desk either by;
Emailing helpdesk at peabody.org.uk
Or by telephone on 020 70214000
Peabody Trust - http://www.peabody.org.uk
Please note that Peabody Trust encorporates Waltham Forest Community Based Housing Association and Safe in the City.
This footnote also confirms that MailMarshal and Network Associates Total
Virus Defense software's have swept this email message for the presence of
computer viruses http://www.marshalsoftware.com and http://www.nai.com