View Single Post
 
Old 08-01-2021, 11:59 PM
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

This Publisher code is annoying to debug. Try this one (again, after selecting the frame where the name should sit). It works for me and appears a bit more robust.
Code:
Sub TestExport()
  Dim sName As String, sPath As String, aRng As TextRange
  Set aRng = Selection.ShapeRange(1).TextFrame.TextRange
  With ActiveDocument.MailMerge.DataSource
    .ActiveRecord = 1
    Do
      sName = .DataFields.Item("Name").Value
      aRng.Text = sName
      'sPath = ActiveDocument.Path & "\" & .DataFields.Item("JpgFileName").Value
      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