Help with Merge to Word Coding

SOLVED

Hi.

I'm using this code to display a Merge to Word button within an ASP file:

if( CRM.Mode == 2) {
if(true){
searchContainer.AddButton(CRM.Button("ButtonMailMerge", "NewDoc.gif", "javascript:document.EntryForm.TargetAction.value = 'NewWordDocument'; document.EntryForm.submit();"));
}

However, its not working quite right when it comes to storing the mail merge it within the companies' communication that follows.An unexpected event has occurred: EOleException: Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

I think it has to do with the Button. But I'm not 100% sure. 
Can someone let me know if the coding above is legit for Sage CRM v2018r3?

Thanks,

Stephan