I may be wrong but this is what I suspect is happening.
- You open MyDoc and then assign MyDoc to ActiveDocument
- At the end you free up MyDoc, but not ActiveDocument
The assignment is essentially redundant. I would suggest that you delete the line "Set ActiveDocument = MyDoc" and change all the references to ActiveDocument to MyDoc.
Give that a shot and let us know whether that worked or not.
Thanks for your replay.
I have tries your suggestion but It didn't work and I am still getting the same error message.
Just to be sure I did ok you ment for this ?
Set MyApp = CreateObject("QlikTech.QlikView")
Set MyDoc = MyApp.OpenDoc ("D:\QlikView\Production\Model\Today_Sales\todaySales.qvw","","")
Set obj = MyDoc.GetSheetObject("CH88")
Set obj = MyDoc.GetSheetObject("CH92")
Set MyDoc = Nothing
Set MyApp = Nothing
I am assuming that the error now refers to MyDoc rather than ActiveDocument.
It seems that the OpenDoc command is not successfully opening the QV document. This could be due to one of the following (which you may have already checked, but in case you havent):
- the path is incorrect. Verify that the document exists at that location, and that the script is running on the same machine as the D: drive.
- the document has section access, and you are not running the script in the correct user context (NTNAME section access), or it requires a username/password in the second and third parameters (not an empty string).
- the document is unavailable due to active directory / NT security settings
- lastly, and I hope not the case, the document is corrupted.
- Something else I haven't thought of.
Can you open the document manually? Is the script running under your username?