6 Replies Latest reply: Jun 14, 2013 11:51 AM by Jim Gay RSS

    setting column widths using a macro

      I have a chart, which is really a table of data with a bunch of columns.  I'd like to set the column widths of a bunch of columns to the same width.  I looked through these discussions and it seemed that a macro was the way to go.  I tried copying some examples, adapting them (so I thought) to my situation.  One used:

           set ch = ActiveDocument.GetSheetObject("CH01")

           ch.SetPixWidth 0, 50

      When I clicked TEST, it didn't like the SetPixWidth.


      I tried another that had:

           set obj = ActiveDocument.GetSheetObject("CH01")

           set objProp = obj.GetProperties

           set objDim = objProp.Dimensions

           objDim(i).ColWidth = 0


      The above shows the lines that I used and changed for my sheet object number.  It didn't like the last statement.


      I know I have no idea what the object model is for QlikView and I'm really just guessing.  I don't know what the members of a sheet object are.  Can anyone either help me with the specific problem of setting a bunch of columns to a specific width, or direct me to some documentation on the object model that might help?



        • Re: setting column widths using a macro
          Marcus Sommer

          Hi Mitch,


          it is a extended version of your trying with a loop through variables to control the width from specific columns. I think it will be helpful.


          sub PrepareColumn


          dim doc, obj, varColumnList, varColumn, varColumnVisible, varColumnWidth, i, ii


          set doc = ActiveDocument

          set obj = doc.GetSheetObject("CH10012")


          varColumnVisible = doc.Variables("vHelpColumnVisible").GetContent.String

          if varColumnVisible = "on" then varColumnWidth = 40 else: varColumnWidth = 0


          varColumnList = doc.Variables("vHelpColumnList").GetContent.String

          varColumn = split(varColumnList, ";")


          for i = 0 to ubound(varColumn)

              if instr(varColumn(i), "-") = 0 then

                  obj.SetPixWidth varColumn(i), varColumnWidth


                  for ii = cint(left(varColumn(i), instr(varColumn(i), "-") - 1)) to cint(mid(varColumn(i), instr(varColumn(i), "-") + 1))

                      obj.SetPixWidth ii, varColumnWidth


              end if



          end sub


          - Marcus