Thread: Office 2003 SP2
View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Cindy M -WordMVP-
 
Posts: n/a
Default Office 2003 SP2

Hi Bdogsputnik,

My code was working fine and recently stopped. Has there been a
security update that's changed things?

Basically my script writes a text file, then opens a word document that
points to it for it's data.

The error I'm getting is: "Compile error: Method or data member not
found"

I don't currently have an installation with Office 2003 SP2, so I can't
test this for you, but...

You use late-binding for the Word application: dim objWord as Object
Then early-binding for the document: Dim oDoc as document

This could be causing some problems if you've lost the reference to the
Word object library. If you do this, does it help:
Dim oDoc as Object

CODE BELOW:

Function MergeIt(DocName As String, PrintIt As String, QueryName As
String)
'Merges a Query (QueryName) with a Word document (the DocName) in
T:\Program Files\GSCB
On Error GoTo MergeItErr
Dim Query2Export As String
Dim File2Create As String
Dim DocLocation As String
Dim WordObj As Object
Dim actWindow As String
Dim MyPath
Dim FoundLabel As Integer
Dim DocNameChange As String
Dim vbResponse
Dim Copies As Integer

MyPath = "T:\Program Files\GSCB"
ChDrive "T"
ChDir "T:\Program Files\GSCB"

If DocName = "Generic Fair Letter" Then
Copies = InputBox("How many copies?")

ElseIf DocName = "Generic Vendor Letter" Then
Copies = InputBox("How many copies?")

End If

'DoCmd.Echo False
'DoCmd.Hourglass True

'Export Speficications
'Set Values
On Error Resume Next
Kill "*.INI"
Kill "*.TXT"
On Error GoTo MergeItErr
Query2Export = QueryName
File2Create = MyPath & "\" & DocName & ".txt"
DoCmd.TransferText acExportMerge, , Query2Export, File2Create,
True

'Launch MsWord

'You can find all these new commands in Word by opening a blank
document,
'pressing Alt + F11, then F2 and searching the words there or looking
'them up in the help file

Set WordObj = CreateObject("Word.Application") 'This is now
the Word object
DocLocation = MyPath & "\" & DocName & ".doc"
Dim oDoc As Document
Set oDoc = WordObj.Documents.Open(FileName:=DocLocation)

'Merge the documents
With oDoc.MailMerge ------------This is the Line
that causes the error
.OpenDataSource Name:= _
File2Create, ConfirmConversions:= _
False, ReadOnly:=False, LinkToSource:=True,
AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False,
Format:=wdOpenFormatAuto, _
Connection:="", SQLStatement:="", SQLStatement1:="", SubType:=
_
wdMergeSubTypeOther
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
'With .DataSource
'.FirstRecord = wdDefaultFirstRecord
'.LastRecord = wdDefaultLastRecord
'End With
.Execute Pause:=False
End With

.............other code removed .............
End Function


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)