Code:
Sub RunMerge()
Dim strWorkbookName As String
strWorkbookName = ThisWorkbook.FullName
Dim wdapp As New Word.Application
Dim wddoc As Word.Document
With wdapp
'Disable alerts to prevent an SQL prompt
.DisplayAlerts = wdAlertsNone
'Open the mailmerge main document
Set wddoc = .Documents.Open("H:\Data\Steven\Master Prototype\Garanties et Options\Master - Garanties.docx")
With wddoc
.ActiveWindow.View.Type = wdNormalView
With .MailMerge
'Define the mailmerge type
.MainDocumentType = wdDirectory
'Connect to the data source
.OpenDataSource Name:=strWorkbookName, ReadOnly:=True, AddToRecentFiles:=False, _
Revert:=False, Format:=wdOpenFormatAuto, Connection:="Data Source=" _
& strWorkbookName & ";Mode=Read", SQLStatement:="SELECT * FROM 'Sheet1'"
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
'Define the output
.Destination = wdSendToNewDocument
'Excecute the merge
.Execute
'Disconnect from the data source
.MainDocumentType = wdNotAMergeDocument
End With
'Close the mailmerge main document
.Close False
End With
'Restore the Word alerts
.DisplayAlerts = wdAlertsAll
'Display Word and the document
.Visible = True
End With
End Sub
I've tried this code and I still have the same pop up (see picture in my initial post). I decided to be more patient and an Excel pop up showed up. I attached the image.
Let me know if you have the solution, thank you in advance.
https://files.fm/u/8p63cjxa
Here's my CSV file without the module in it so if you test it out (copy paste my code in a new module in the file). I re-uploaded the CSV because I just checked the link in my past post is a dead link.