View Single Post
 
Old 07-30-2021, 05:40 AM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Hmm, yes, I tested it on my machine and I got the same result as you even though the preview showed the right thing.

OK, try this instead. Get rid of the merge fields from the page and make sure the cursor is sitting in the text frame where you want the name to appear. (The text frame should be otherwise empty so use a different frame than the good wishes lines). Then try this version of the macro.
Code:
Sub TestExport()
  Dim sName As String, sPath As String, aRng As TextRange
  Set aRng = Selection.TextRange
  With ActiveDocument.MailMerge.DataSource
    .ActiveRecord = 1
    Do
      sName = .DataFields.Item("Name").Value
      aRng.Paragraphs(1).Text = sName
      sPath = .DataFields.Item("JpgFolderPath").Value & "\" & .DataFields.Item("JpgFileName").Value
      ActiveDocument.Pages(1).SaveAsPicture Filename:=sPath, pbResolution:=pbPictureResolutionWeb_96dpi
      If .ActiveRecord = .RecordCount Then Exit Do
      .ActiveRecord = .ActiveRecord + 1
    Loop
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote