#1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
bdogsputnik
 
Posts: n/a
Default Office 2003 SP2

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"

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


Any help? Thanks!

  #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 :-)

  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
bdogsputnik
 
Posts: n/a
Default Office 2003 SP2

For those who find this article later.

The answer was that:

Dim oDoc as Document

should be changed to:

Dim oDoc as Word.Document

Happy Coding!

Brian
Envision Consulting
Business Technology Solutions for Small Businesses
http://www.envisionyourvision.com

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I get free updates to Word 2003 without Office 2003 MarkTWAIN99 New Users 5 July 23rd 05 05:33 PM
Using a default User Template (Office 2003) [email protected] Microsoft Word Help 1 June 15th 05 10:09 AM
How can I move my word styles from Office 2000 to Office 2003 on . Northof60 Microsoft Word Help 2 March 29th 05 11:16 PM
After upgrade from office 2000 to office 2003 Graphic Appears as . Officeguy Microsoft Word Help 0 February 8th 05 02:55 AM
MS Office 2003 Word Document Icons dhprof Microsoft Word Help 1 November 30th 04 06:33 PM


All times are GMT +1. The time now is 08:27 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"