6 Replies Latest reply: Jun 5, 2017 10:10 AM by Craig Leite RSS

    Vbscript error when trying to reload and export

    Yaniv Egozi

      G'day All,

      I have a which shows today sales in a simple chart (pivot table) which I want to export to excell and send by email. after reading many posts here I have created a vbscript which open the QVW reload it, make the export and then execute a macro that send the email.

      everything worked fine the first few times I have tested it but today when ever I run the vbscript I am getting the following error:

      "Script:
      c:\user\...\todaysales.vbs
      Line: 4
      Char:1
      Error: Object required: 'ActiveDocument'
      Code: 800A01A8
      Source: Microsoft VBScript runtime error"

      /cfs-file.ashx/__key/CommunityServer.Discussions.Components.Files/12/2845.script_2D00_error.jpg

      My script is:

      Set MyApp = CreateObject("QlikTech.QlikView")
      Set MyDoc = MyApp.OpenDoc ("D:\QlikView\Production\Model\Today_Sales\todaySales.qvw","","")
      Set ActiveDocument = MyDoc
      ActiveDocument.Reload
      Set obj = ActiveDocument.GetSheetObject("CH88")
      Obj.ExportBiff "C:\temp\todayavaragesales.xls"
      Set obj = ActiveDocument.GetSheetObject("CH92")
      Obj.ExportBiff "C:\temp\todaysales.xls"
      ActiveDocument.GetSheetObject("BU01").Press
      ActiveDocument.Save

      Set MyDoc = Nothing
      MyApp.Quit
      Set MyApp = Nothing

      /cfs-file.ashx/__key/CommunityServer.Discussions.Components.Files/12/2845.script_2D00_error.jpg

      The only way to solve it is to restart the computer, but after running o.k for one time the error starting again.
      I am using win 2008 server 64bit and running qlikview 9 SR5

      Any help would be appreciated

      10x in advance

        • Vbscript error when trying to reload and export
          Yaniv Egozi

          Attached a capture of the error message

          • Vbscript error when trying to reload and export
            Jonathan Dienst

            Hi

            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.

            Jonathan

              • Vbscript error when trying to reload and export
                Yaniv Egozi

                Hi Jonathan,

                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","","")
                MyDoc.Reload
                Set obj = MyDoc.GetSheetObject("CH88")
                Obj.ExportBiff "C:\temp\todayavaragesales.xls"
                Set obj = MyDoc.GetSheetObject("CH92")
                Obj.ExportBiff "C:\temp\todaysales.xls"
                MyDoc.GetSheetObject("BU01").Press
                MyDoc.Save

                Set MyDoc = Nothing
                MyApp.Quit
                Set MyApp = Nothing

                  • Vbscript error when trying to reload and export
                    Jonathan Dienst

                    Hi

                    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?

                    Jonathan

                • Re: Vbscript error when trying to reload and export
                  James Phillips

                  Did anyone ever figure this out? I am receiving Object Required... Once I restart PC it runs once fine

                   

                  11-9-2014 1-08-27 PM.jpg