I try to modified a current spreadsheet that I did not created.
In the excel file a button was created to do these step :
Create new .CSV file
Open my Word master
Create word document with my .csv file
Close and save the .csv file.
When the word document open, they did not ask to select text code. As a default, the Japonese code is select. So cute, but not good.
Sould I change something in this ? Thank you in advance
Code:
With wdapp
'Disable alerts to prevent an SQL prompt
.DisplayAlerts = wdAlertsNone
'Open the mailmerge main document
Set wddoc = .Documents.Open("C:\Users\Test.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