Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I want to change the selection colors in one Qlikview application where I have the possibility to define the colors in the load script. When I define the selection color directly in the Macro, everything works well. The macro looks like follows:
MACRO:
Sub SetColorPrefs()
dim UserPrefs
set UserPrefs = ActiveDocument.GetApplication.GetUserPreferences
UserPrefs.CustomSelBgColor(1).PrimaryCol.Col = RGB(255,0,0)
ActiveDocument.GetApplication.SetUserPreferences UserPrefs
End Sub
I then tried to put the RGB setting in the loadscript in a variable and to refer to the variable in the macro. Unfortunately the macro does not accept this.
LOAD SCRIPT:
set vColor = RGB(255,0,0);
MACRO:
Sub SetColorPrefs()
dim UserPrefs
set User Prefs = ActiveDocument.GetApplication.GetUserPreferences
UserPrefs.CustomSelBgColor(1).PrimaryCol.Col = ActiveDocument.Variables("vColor").GetContent.String
ActiveDocument.GetApplication.SetUserPreferences UserPrefs
End Sub
My Overall target is to define the Color Settings in the load script or even in an external file which users can modify easily.
Does anyone have an idea how I can make this work?
Thanks a lot in advance for your help
This is not a per document setting. The macro changes the user preferences in the setting.ini file somewhere down in the users AppData folder. If your users access the document via Qlikview Server then this setting won't work unless you put it into the settings.ini file on the server. Note that the changed setting will apply to all users for all documents on your Qlikview Server.
You could try modifying this extension to do what you want: Document Extension to override green selection color
Hi,
In fact RGB() is a VBS function that return a number : https://www.w3schools.com/asp/func_rgb.asp
>> UserPrefs.CustomSelBgColor(1).PrimaryCol.Co is waiting for a number !
The solution is prety simple in fact. Use the Eval() function to "evaluate" the result of your RGB(255,0,0) string : https://www.w3schools.com/asp/func_eval.asp
Sub SetColorPrefs()
dim UserPrefs
set User Prefs = ActiveDocument.GetApplication.GetUserPreferences
UserPrefs.CustomSelBgColor(1).PrimaryCol.Col = Eval(ActiveDocument.Variables("vColor").GetContent.String)
ActiveDocument.GetApplication.SetUserPreferences UserPrefs
End Sub
It works perfectly for me