官术网_书友最值得收藏!

Modifying the green, white, and gray selection color schemes

QlikView selection colors are green/white/gray. They have a brand around this and are not keen for anyone who can change them.

It is, however, possible to do so. We will use the QlikView API to modify the user's color preferences.

Getting ready

Open any existing QlikView document with at least one listbox (perhaps one of the documents from Chapter 1, Charts).

How to do it

Follow these steps to change the default green, white, and gray color schemes:

  1. From the Tools menu, select Edit Module (or press Ctrl + M).
  2. Enter the following code:
    Sub SetColorPrefs()
    
      Dim UserPrefs
      
      set UserPrefs = _
        ActiveDocument.GetApplication.GetUserPreferences
    
      ' Set the "Selected" Color
      UserPrefs.CustomSelBgColor(1).PrimaryCol.Col = _
        RGB (0,0,255)    ' Blue
      UserPrefs.CustomSelFgColor(1).PrimaryCol.Col = _
        RGB (255,255,0)  ' Yellow
      ' Set the "Possible" Color
      UserPrefs.CustomSelBgColor(2).PrimaryCol.Col = _
        RGB (255,255,0)  ' Yellow
      UserPrefs.CustomSelFgColor(2).PrimaryCol.Col = _
        RGB (0,0,0)      ' Black
      ' Set the Excluded Color
      UserPrefs.CustomSelBgColor(5).PrimaryCol.Col = _
        RGB (200,200,200) ' Light gray
      UserPrefs.CustomSelFgColor(5).PrimaryCol.Col = _
        RGB (0,0,0)  ' Black
    
      ' Set the Locked Color
      UserPrefs.CustomSelBgColor(0).PrimaryCol.Col = _
        RGB (255,0,0) ' Red
      UserPrefs.CustomSelFgColor(0).PrimaryCol.Col = _
        RGB (0,0,0)  ' Black
    
      ActiveDocument.GetApplication.SetUserPreferences _
        UserPrefs
    
    end sub
  3. Click on the Check button to test for syntax errors. It should display "*** Ready ***".
  4. Click on the Test button to execute the code.
  5. Click on OK to close the editor.
  6. From the Settings menu, open Document Properties (or press Ctrl + Alt + D).
  7. Under Color Scheme, select [Custom]. Click on OK.
  8. Note that the new color scheme has been applied.

How it works…

The API call assigns a UserPreferences object to a variable, which allows us to modify each of the background and foreground colors for the following indexes:

Most of the time you probably don't need to set all of these as some of them are rarely used.

Once we have set all the background and foreground colors, we can then assign the UserPreference object as the user preferences for the current user. This causes the options to be written to the user's Settings.ini file in C:\Users\username\AppData\Roaming\QlikTech\QlikView.

It is worth noting that multiple users in an organization should not use multiple different colors for selections, and so on. This could cause a lot of confusion!

There's more…

The API gives us access to a lot of settings like this, which have no UI to allow them to be set otherwise.

By default, QlikView installs a PDF and a very useful QVW file, that fully documents the API functionality, in C:\ProgramData\QlikTech\QlikView Documentation\Automation.

See also

  • The Changing the default selection color scheme recipe
  • The Modifying the green, white and gray selection color schemes on QlikView Server recipe
主站蜘蛛池模板: 兴国县| 景德镇市| 扎兰屯市| 普安县| 宝兴县| 桂平市| 涡阳县| 平武县| 安丘市| 克什克腾旗| 天津市| 汶上县| 灵石县| 罗源县| 宜州市| 罗甸县| 望江县| 甘南县| 高雄县| 津南区| 阳江市| 乐平市| 广昌县| 葫芦岛市| 阳信县| 福建省| 襄城县| 准格尔旗| 望奎县| 东丰县| 岳阳市| 太和县| 天峻县| 铜川市| 靖安县| 镇原县| 宜兰市| 林口县| 垣曲县| 广宁县| 永丰县|