Discussion Board for collaboration related to QlikView App Development.
I’m trying to export a series of objects (charts) from a server .qvw via an external VB script. It's a straightforward section of code for this output, and it works with 4 out of 5 objects, however the 5th object throws the error of ‘object variable not set’ if there is no error handling in place. The first 4 objects are document objects, visible to all users on each session, whereas the 5th is a shared server object with the object ID format “CHxx-xx”.
The idea is this is part of a larger piece of automation to export objects daily as pivot tables/straight tables via a shared drive to a number of external users who do not have access to QV
The extract of code is as below:
For i = 1 To 5 Set QVObj = QVDoc.GetSheetObject(ObjectWs.Cells(i, 3).Value) On Error Resume Next ExportFilePath = "C:\Users\HOLLAND\QVObjects\" & ObjectWs.Cells(i, 3).Value & ".csv" ExportFileName = ObjectWs.Cells(i, 3).Value & ".csv" QVObj.ExportBiff (ExportFilePath) ActiveWorkbook.FollowHyperlink (ExportFilePath) Next i
The 5 objects (listed in order on ObjectWs) are:
CH02 |
CH04 |
CH12 |
CH37 |
CH46-02 |
All 5 objects exist as when I export the CH46-02 object manually, the prefix on the resultant .csv is CH46-02.
I must be missing something minor, but is there a separate object command I need to be using? ‘GetSheetObject’ works fine for the first 4, but fails for the 5th, I know it doesn’t exist but it feels like ‘GetServerObject’ method is required instead, or something similar?
Any help greatly appreciated!
Thanks
Dave
I'm not absolutely sure but I think it couldn't work because this isn't a real object within the application else it's an external xml-code (within the shared-files) with the object-properties. You could look if you find any related postings to the export of serverobjects and/or trying to play with serversideexport-statements but I think it would be more practically to rebuild this table as a native object within this application.
- Marcus
Thanks for the reply Marcus,
I think you're correct, I tried the same piece of code with a document version of the same .qvw with an object ID pointing to a newly created chart (with an identical ID to the problematic object above) and it exported all 5 just fine.
It's an odd quirk because although the object ostensibly looks like it is native to the table, making it a shared object means it isn't. I'd have thought that the code should still work, providing there is an object with that ID in the active file you're working on, throwing an error only if the object didn't exist whatsoever.
As they're relatively simple pivots I'd toyed with the idea of scripting in the creation of a pivot and having the fields added in upon each run, though my concern was that once I'd created it, I might then run into the same issue of it not being a native object.
I think the logical solution would be to add the chart in as a native object as you say.
Thanks again for your input it's greatly appreciated.
Dave
You are opening the document from the file system, not through access point correct? The shared objects would not be available unless you were using the server interface.
-Rob