View Single Post
 
Old 05-27-2021, 04:07 AM
JamesWood JamesWood is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Nov 2020
Posts: 37
JamesWood is on a distinguished road
Question Public function string problem

Hi guys


I have this public string code:


Public Function docNameFieldPreview() As String
docNameFieldPreview = ActiveDocument.MailMerge.DataSource.DataFields("Name").Value
End Function


This works, but if I replace the name section with another string I have, it says "The requested member of the collection does not exist."


Public Function docNameFieldPreview() As String
docNameFieldPreview = ActiveDocument.MailMerge.DataSource.DataFields(docNameField).Value
End Function


Any thoughts? docNameField has been dimmed elsewhere, and does work in other areas of the code that use it, so I'm not sure why it won't work in this particular string.


Thanks a lot
James
Reply With Quote