B
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"
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!
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!