Why does the code have "With Word" followed by "Word.Visible"? Isn't that the department of redundancy department? Try it first without the "Word" preceding the ".Visible" to see what happens.
I am assuming that the appropriate reference has been set to be able to reference MS Word functions.
Jeff
To: "MS Access Professionals" <MS_Access_Professionals@yahoogroups.com>
Sent: Sunday, January 4, 2015 8:14:06 PM
Subject: [MS_AccessPros] Automation Access 2013/Word 2013-Error has occurred: The database has been placed in a state by user 'Admin'.....locked
When Bold line is executed the error appears.
Private Sub cmEOD_Click()
'1-populate tblLetterInfo
Dim Wrd As New Word.Application
Dim strMergeDoc As String
Dim strFileTempWord As String
Dim strFileWord As String
Dim objApp As Object
Dim MyQuery As String
Dim Word As Word.Application
Dim Form As Word.Document
Dim strSource As String
strSource = "F:\ISMA\WORD\WriteToWord.accdb"
strMergeDoc = "F:\ISMA\wordtemplates\NSF1.dotx"
Set Word = CreateObject("Word.Application")
Word.Documents.Open strMergeDoc
With Word
Word.Visible = True
.ActiveDocument.MailMerge.OpenDataSource Name:=strSource, linktosource:=True, ReadOnly:=True, addtorecentfiles:=False, Connection:="tblLetterInfo"
.ActiveDocument.SaveAs2 strFileTempWord
If .ActiveDocument.MailMerge.State = wdMainAndDataSource Then
.ActiveDocument.MailMerge.Destination = wdSendToNewDocument
.ActiveDocument.MailMerge.Execute
End If
End with
............................................................................................
Thanks
Norbert
--
Jeffrey Park Jones
Excel, Access, Word, Office Expert
Excel and Access, LLC®
http://ExcelAndAccess.Com
919-671-9870
5109 Deer Lake Trail
Wake Forest, NC 27587
jpjones23@centurylink.net
Posted by: jpjones23@centurylink.net
| Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (2) |
Tidak ada komentar:
Posting Komentar