Issue with dataset.display in illustrator4
I'm opening a document, importing a XML with dataset using activeDocument.importVariables and then displaying the dataset. When I run the code on already opened document then it dataset is changed and displayed in illustrator document but if I open a new document through code and then execute the code to import variables and display dataset then dataset is not displayed. Below is my code for both the cases.
1) When document already opened
activeDocument.importVariables(File ('/E/Projects/Illustrator/Temp/TempFile.xml'));
app.activeDocument.activeDataset = activeDocument.dataSets.getByName("CURRENT");
app.activeDocument.activeDataset.display();
This code runs without problems and changes variable values are displayed.
2) When code for opening the document is executed
var myDocument = app.open(File("/E/Projects/Illustrator/Templates/test6.ait"));
myDocument.activate();
activeDocument.importVariables(File ('/E/Projects/Illustrator/Temp/TempFile.xml'));
app.activeDocument.activeDataset = activeDocument.dataSets.getByName("CURRENT");
app.activeDocument.activeDataset.display();
Values of active dataset is not shown in the document and in the variables panel , selected dataset is not shown selected though variables are imported successfully.
Do I need to do something else to show the dataset?