Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
I am getting below error when i click on the Mail Merge button in code --
Method 'Run' of Object '_Application' Fail amd it is asking for the password code is as below Private Sub MergeMailDoc(as_Path As String, as_DocName As String, as_Where As String) Dim ls_DbConnection As String Dim ls_SqlStatement As String Dim ls_DocPathName As String Dim ls_DocName As String 'Windows("ExamSpec.doc").Activate Documents("ExamSpec.doc").Activate Selection.EndKey Unit:=wdStory ls_DocName = as_DocName ls_DocPathName = as_Path & "\" & ls_DocName If Len(Dir(ls_DocPathName)) = 0 Then ls_DocName = "NoExamSpec.doc" ls_DocPathName = as_Path & "\" & ls_DocName End If Application.Documents.Open ls_DocPathName ls_DbConnection = as_Path & "\Prs_Data.mdb" ls_SqlStatement = "SELECT * FROM `ExamSpecReport` " & as_Where Documents("ExamSpec.doc").Application.Run "Mail_Merge", ls_DocName, ls_DbConnection, ls_SqlStatement Documents("ExamSpec.doc").Application.Run "AppendMailMerge" Documents(ls_DocName).Close False End Sub ************************************************** ** Private Sub Mail_Merge( _ as_DocName As String, _ as_DbConnection As String, _ as_SqlStatement As String) ' ================================================== ============================================= ' PURPOSE: Implement the built in mail merge functionality provided by MS Word ' ' INVOCATION: Macro within this document ' ' ASSUMPTIONS: None ' ' EFFECTS: tblJobs ' ' INPUTS: as_DocName - Output document name ' as_DbConnection - Full data source path name ' as_SqlStatement - Data source E.g "SELECT * FROM `ExamSpecReport` WHERE... ' ' RETURN: None ' ' COMMENTS: ' ' WRITTEN BY: (Advantica) DATE: - ' ================================================== ============================================= ' HISTORY: ' Initials Date Comment ' Claud G 06/12/05 Added Subtype:=wdMergeSubTypeWord2000. This suppresses the datalink ' properties dialogue from continually appearing when word connects to the ' MS Access data source. ' ================================================== ============================================= With Documents(as_DocName).MailMerge .OpenDataSource _ Name:=as_DbConnection, _ ConfirmConversions:=False, _ ReadOnly:=False, _ LinkToSource:=True, _ AddToRecentFiles:=False, _ PasswordDocument:="", _ PasswordTemplate:="", _ WritePasswordDocument:="", _ WritePasswordTemplate:="", _ Revert:=False, _ Format:=wdOpenFormatAuto, _ Connection:="DSN=MS Access Database;DBQ=" & as_DbConnection & ";PWD=" & ms_DbPassword & ";DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;", _ SQLStatement:=as_SqlStatement, _ SQLStatement1:="", _ Subtype:=wdMergeSubTypeWord2000 ' Makes sure the mailmerge behaves as in Word2K .Destination = wdSendToNewDocument .MailAsAttachment = False .MailAddressFieldName = "" .MailSubject = "" .SuppressBlankLines = True With .DataSource .FirstRecord = 1 .LastRecord = 1 End With .Execute Pause:=True End With End Sub |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Mail-Merge: Can we have master detail relationship or multiple entities in word Mail-Merge? | Microsoft Word Help | |||
Take Mail Merge in Word back the the Mail Merge Helper 1,2,3 Form. | Mailmerge | |||
Mail merge has lost significant functionality in Word 2003 | Mailmerge | |||
Proteced Form with Mail Merge Section-Mail Merge is "lost" whe | Microsoft Word Help | |||
mail merge doc with further linked/embedded mail merge docs not playing the game | Mailmerge |