document.MailMerge.GetFieldNames()

I getting the “Object Not set to an instance in below code”

Dim document As Aspose.Word.Document. = Nothing
document .MailMerge.GetFieldNames()

Aspose Version = .ver 11:10:0:0

Please suggest the possible to get the solution.

Hi,

Thanks for your inquiry. You are getting this exception because the Document object is set to Nothing. Please use New keyword to create an instance of a Document class as shown in following code snippet.

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

'Creates a blank Word document
Dim doc1 As New Document 'GetFieldNames method returns a collection of mail merge field names available in the document.
Dim fieldnames1 As String() = doc1.MailMerge.GetFieldNames()
'Opens an existing document from a file
Dim doc As New Document("in.docx")
Dim fieldnames2 As String() = doc1.MailMerge.GetFieldNames()

We are getting the exception "Object Not set to reference " when we using the document.MailMerge.GetFieldNames() with the document has word merge field without the merge field name.
Please help us to proceed.

Hi,

Thanks for your inquiry.

I would suggest you please upgrade to the latest version of Aspose.Words (v13.2.0) from here and let us know how it goes on your side. If the problem still remains, please attach your input Word document here for testing. I will investigate the issue on my side and provide you more information.