Thread: csv issue
View Single Post
 
Old 10-30-2014, 02:35 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,363
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

There may, of course, be an issue with the way you're automating Word, rather than with Word itself. In any event, since you're automating Word, you might do better to save the document as a normal document (with mergefields, etc. in place) and add the mailmerge process to the automation code itself. For example:
Code:
Sub RunMerge()
' Demo code for a vba-driven mailmerge.
Dim wdApp As New Word.Application
Dim wdDoc As Word.Document
wdApp.DisplayAlerts = wdAlertsNone
Dim StrSrc As String, StrDoc As String
StrDoc = "C:\Users\" & Environ(UserName) & "\Downloads\MergeDoc.doc"
StrSrc = "C:\Users\" & Environ(UserName) & "\Downloads\DataFile.csv"
Set wdDoc = wdApp.Documents.Open(StrDoc)
With wdDoc
  With .MailMerge
    .MainDocumentType = wdFormLetters
    .OpenDataSource _
      Name:=StrSrc, ReadOnly:=True, AddToRecentFiles:=False, LinkToSource:=False, _
      Connection:="", SQLStatement:="", SQLStatement1:="", SubType:=wdMergeSubTypeOther
    .Destination = wdSendToNewDocument
    .SuppressBlankLines = True
    With .DataSource
      .FirstRecord = wdDefaultFirstRecord
      .LastRecord = wdDefaultLastRecord
    End With
    .Execute Pause:=False
    .MainDocumentType = wdNotAMergeDocument
  End With
  .Close False
End With
wdApp.DisplayAlerts = wdAlertsAll
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote