Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good morning,
it's my first message in this board because I always found everything I needed.
There's something I didn't find and I'm trying to understand if it's impossible to do.
So..let me explain what I'd like.
I've a qvw document script like that:
LOAD Customer,
[Sales Order ID],
ShipDate,
Product,
VBGetValue() AS FromDotNet,
Sales,
Quantity
FROM
[Sales Orders.xls]
(biff, embedded labels, table is [Sales Orders$]);
VBGetValue is a function defined in the Edit Module window:
function VBGetValue()
dim myObj
Set myObj = CreateObject("MyNamespace.MyClass")
VBGetValue = myObj.myMethod(ActiveDocument)
end function
I'm able to communicate with my registered C# DLL and to know the right type of COM ActiveDocument object: it's a Doc.
So..i tried to cast in the C# side this parameter with Doc class within Interop.QlikView.dll in this way:
public string myMethod(object a)
{
try
{
var doc = (Doc) a;
return doc.Name;
}
catch (Exception ex)
{
return ex.Message;
}
}
And this is the Exception Message caught:
Error HRESULT E_FAIL has been returned from a call to a COM component. MyClass -2147467259 at QlikView.Doc.get_Name()
What's wrong?
Your main impediment here and actually a roadblock is that when a load script is running the QlikView object model is not available. It seems to me that your are trying to access the currently running load script's object model - right? QlikView Desktop can be in one of two phases. Running load script and executing the application that use the data model that the load script produced. These phases aren't overlapping. And only the second phase instantiate and make available a COM Object Model.
At no time during load script execution is there any contact with the QlikView Object Model. The only thing you can get in contact with is the standard VBScipt (or JScript) engine of the Windows OS. This VBScript only has access to the standard features as documented by Microsoft. That is why the VBGetValue() actually works. But your C# code - from what you show us can't make any calls back to an object that is not available or does not exist.
Only afterwards when the load script has finished and made ready the in-memory data model for consumption of a QlikView session will the QV Object Model be available. The connection point from a COM-perspective is that you are first connected to either QlikView Desktop or QlikView Server and then you can through COM either get the ActiveDocument or Open an existing QVW-file/document or create a new document. So Macros/Modules invoked through the UI of either QV Desktop, IE plug-in (Internet Explorer only), QV OCX or even a regular web-browser (with limitations of functionality for this specific option).
So in your C# you can't get in contact with an object model of the application that is running the load script. A hack that would be rather odd would be that you could be able to independently connect directly with QlikView in a separate instance of QlikView (maybe) and then open an old/previous instance of a document. That would seem very convoluted and without knowing your use-case I would advice strongly against anything like that...
Maybe this is helpful: Calling a DLL function in my QV script ...
- Marcus
Unfortunately not!
Your main impediment here and actually a roadblock is that when a load script is running the QlikView object model is not available. It seems to me that your are trying to access the currently running load script's object model - right? QlikView Desktop can be in one of two phases. Running load script and executing the application that use the data model that the load script produced. These phases aren't overlapping. And only the second phase instantiate and make available a COM Object Model.
At no time during load script execution is there any contact with the QlikView Object Model. The only thing you can get in contact with is the standard VBScipt (or JScript) engine of the Windows OS. This VBScript only has access to the standard features as documented by Microsoft. That is why the VBGetValue() actually works. But your C# code - from what you show us can't make any calls back to an object that is not available or does not exist.
Only afterwards when the load script has finished and made ready the in-memory data model for consumption of a QlikView session will the QV Object Model be available. The connection point from a COM-perspective is that you are first connected to either QlikView Desktop or QlikView Server and then you can through COM either get the ActiveDocument or Open an existing QVW-file/document or create a new document. So Macros/Modules invoked through the UI of either QV Desktop, IE plug-in (Internet Explorer only), QV OCX or even a regular web-browser (with limitations of functionality for this specific option).
So in your C# you can't get in contact with an object model of the application that is running the load script. A hack that would be rather odd would be that you could be able to independently connect directly with QlikView in a separate instance of QlikView (maybe) and then open an old/previous instance of a document. That would seem very convoluted and without knowing your use-case I would advice strongly against anything like that...
Which kind of information respectively values should be really returned from VBGetValue() - maybe there are other ways to get them - probably not the documentname() or is it?
- Marcus
Yes Marcus. You are right!
What I need is to pass arrays of data from resident tables and return back them.
Is it possible to pass fields values?
Thank you very much!
Do you mean with "resident tables" already in these qvw loaded data? If yes then they are in general accessable. Could you give a more practically example to them - how and where loaded and where should they be access again?
- Marcus
Sure Marcus,
my intentions are like the image below.
I would like to pass a field and to return a modified "Product" value through VBScript (and maybe within the VBScript be able to call a c# dll passing the field value)
I hope it's clear.
Thank you in advance!
In which way should "Product" be modified? Please give an example for a typical input- and output-value.
- Marcus