<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro call to oCol.Name fails for expressions in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-call-to-oCol-Name-fails-for-expressions/m-p/987836#M336809</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could read the chart cell for cell within a loop including the header and check them in an if-loop, see here an example from APIGuide.qvw:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set table = ActiveDocument.GetSheetObject( "CH01" )&lt;/P&gt;&lt;P&gt;w = table.GetColumnCount&lt;/P&gt;&lt;P&gt;h = table.GetRowCount&lt;/P&gt;&lt;P&gt;set CellMatrix = table.GetCells2(0,0,w,h)&lt;/P&gt;&lt;P&gt;for RowIter=0 to h-1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for ColIter=0 to w-1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msgbox(CellMatrix(RowIter)(ColIter).Text)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; next&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Aug 2015 11:52:26 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2015-08-25T11:52:26Z</dc:date>
    <item>
      <title>Macro call to oCol.Name fails for expressions</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-call-to-oCol-Name-fails-for-expressions/m-p/987833#M336806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Long story short: I need to write a macro that can look up columns in a straight table / table box, based on the field name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It all works perfectly well, with one little snag: the macro call &lt;SPAN style="font-family: 'andale mono', times; font-size: 13.3333330154419px;"&gt;oCol.Name &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;fails if the column is an expression, or a calculated dimension. Even if I set a label. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Any ideas to fix or get around this, please?&lt;/P&gt;&lt;PRE&gt;Function ReadChartColumns()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim oCol, oTable, sChartId

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sChartId = "CH01"


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MsgBox "DBG: Getting columna names from '" &amp;amp; sChartId &amp;amp; "'"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set oTable = ActiveDocument.GetSheetObject(sChartId)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MsgBox "DBG: Reading " &amp;amp; oTable.GetColumnCount &amp;amp; " columns from '" &amp;amp; sChartId &amp;amp; "'"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For iCol = 0 To oTable.GetColumnCount-1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'MsgBox "DBG: Getting column: " &amp;amp; iCol
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set oCol = oTable.GetField(iCol)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MsgBox "DBG: Got column: " &amp;amp; iCol
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sField = oCol.Name&amp;nbsp;&amp;nbsp;&amp;nbsp; ' This line fails
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MsgBox "DBG: Got column " &amp;amp; iCol &amp;amp; " field name: " &amp;amp; sField
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next
End Function&lt;/PRE&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Vegard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 07:42:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-call-to-oCol-Name-fails-for-expressions/m-p/987833#M336806</guid>
      <dc:creator>vegard_bakke</dc:creator>
      <dc:date>2015-08-25T07:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Macro call to oCol.Name fails for expressions</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-call-to-oCol-Name-fails-for-expressions/m-p/987834#M336807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All columns are not connected to fields so it is dangerous to assume that the GetField() returns a field object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try using this snippet in your function to see what you get:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set stp = oTable.GetProperties&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set exps = stp.Expressions&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set expr = exps.Item(0)(0).Data.ExpressionData&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox expr.Definition.v&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will return both expressions but also field names .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The object model of QlikView is quite hierarchical and can seem a bit convoluted .....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 09:29:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-call-to-oCol-Name-fails-for-expressions/m-p/987834#M336807</guid>
      <dc:creator>petter</dc:creator>
      <dc:date>2015-08-25T09:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macro call to oCol.Name fails for expressions</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-call-to-oCol-Name-fails-for-expressions/m-p/987835#M336808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is definitely the right answer to my question.&amp;nbsp; Unfortunately, I didn't tell you what I need the column name for. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to export the some of the columns in a straight table in a peculiar way. My idea was to use the column name as identification/lookup. &lt;SPAN style="font-size: 8pt;"&gt;(I could use column numbers, but it is difficult to read, difficult to maintain, and adding new columns would possibly break the export.)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore I looking for a way to iterate:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '&lt;EM&gt;Column name / label / tag&lt;/EM&gt;' &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;combined with '&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;EM&gt;Row number&lt;/EM&gt;', which could give me the '&lt;EM&gt;Cell value&lt;/EM&gt;'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've search through the Qlik's API Guide. But I haven't found a link to the column number, or another way of identifying a cell, from the IArrayOfArrayOfMainExpressionData, IMainExpressionData, IChartDimensionData in the solution above. Or any other classes, for that matter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the API has many members, and I might have missed an easy solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone see a solution to my problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Vegard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 11:22:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-call-to-oCol-Name-fails-for-expressions/m-p/987835#M336808</guid>
      <dc:creator>vegard_bakke</dc:creator>
      <dc:date>2015-08-25T11:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: Macro call to oCol.Name fails for expressions</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-call-to-oCol-Name-fails-for-expressions/m-p/987836#M336809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could read the chart cell for cell within a loop including the header and check them in an if-loop, see here an example from APIGuide.qvw:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set table = ActiveDocument.GetSheetObject( "CH01" )&lt;/P&gt;&lt;P&gt;w = table.GetColumnCount&lt;/P&gt;&lt;P&gt;h = table.GetRowCount&lt;/P&gt;&lt;P&gt;set CellMatrix = table.GetCells2(0,0,w,h)&lt;/P&gt;&lt;P&gt;for RowIter=0 to h-1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for ColIter=0 to w-1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msgbox(CellMatrix(RowIter)(ColIter).Text)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; next&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 11:52:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-call-to-oCol-Name-fails-for-expressions/m-p/987836#M336809</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2015-08-25T11:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro call to oCol.Name fails for expressions</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-call-to-oCol-Name-fails-for-expressions/m-p/987837#M336810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's true, however some columns are for display only, and cannot be exported (breaks the specification).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I need to somehow specify each column I shall export.&lt;/P&gt;&lt;P&gt;(Preferably without relying on the column number.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Vegard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 11:56:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-call-to-oCol-Name-fails-for-expressions/m-p/987837#M336810</guid>
      <dc:creator>vegard_bakke</dc:creator>
      <dc:date>2015-08-25T11:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro call to oCol.Name fails for expressions</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-call-to-oCol-Name-fails-for-expressions/m-p/987838#M336811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe other ways are easier, for example to use specialized objects for exports, reporting and printing on a hidden sheet (almost ever I use this approach) or to export objects completely and remove unnecessray content within excel, maybe in a master-file which included such a routine in an OnClose trigger.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 12:11:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-call-to-oCol-Name-fails-for-expressions/m-p/987838#M336811</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2015-08-25T12:11:35Z</dc:date>
    </item>
  </channel>
</rss>

