rajashekarnaidu
New Member
- Joined
- Oct 19, 2017
- Messages
- 1
Dear Forum Members,
This is my first post though I have been visiting the site for help very often.
I have a code where the word document asks for the recipient list and than sends email messages to the list in the spreadsheet. This works absolutely fine on my system and couple of my colleagues system. Recently I was asked to send this file with users in different country. But the code isn't working.
The code is below, it debugs at line ".Execute Pause:=False". hoping the experts could help me with this.
This is my first post though I have been visiting the site for help very often.
I have a code where the word document asks for the recipient list and than sends email messages to the list in the spreadsheet. This works absolutely fine on my system and couple of my colleagues system. Recently I was asked to send this file with users in different country. But the code isn't working.
The code is below, it debugs at line ".Execute Pause:=False". hoping the experts could help me with this.
Code:
Sub ABC()
Dim fd As Office.FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
.Title = "file name"
.Filters.Clear
.Filters.Add "All Files", "*.*"
If .Show = True Then
FName = .SelectedItems(1)
End If
End With
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:=FName, _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=" & FName & ";Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Engine Type=37;Jet " _
, SQLStatement:="SELECT * FROM `Sheet1$`", SQLStatement1:="", SubType:= _
wdMergeSubTypeAccess
With ActiveDocument.MailMerge
.Destination = wdSendToEmail
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
End Sub
Last edited by a moderator: