Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
laujerry
Creator
Creator

qlikview macro - getcolumncount incorrect

Hi all,

i am writing a macro to generate excel file

in my qvw i hv several buttons to trigger hide/show chart or select dimension of chart

e.g.

there are 2 charts and 4 buttons

button 1 and 2 will show chart 1 with different dimension selection, button 3 and 4 will show chart 2 with different dimension selection

now i will simulate the 4 button click in my macro to generate the 4 charts and put them in 4 separate sheets in one single excel file

i found that if i use this in my macro:

For ...

   ...

   ' press a button before get sheet object

   Set x = ActiveDocument.GetSheetObject(varChartObjectID)

   varColCount = x.GetColumnCount

   ...

   Call x.CopyTableToClipboard(true)

   ...

   ' use this varColCount to do formatting to the last column

   ...

next

the varColCount is sometimes wrong, which is always 1 column less if happens

at the same time, if such issue occurs, it does not appear in all sheets

but the chart is always complete (with all columns shown)

Please try commenting and thanks to all

4 Replies
Not applicable

Can u say in what cases it gives incorrect count???

Because when i am doing its proper everytime

laujerry
Creator
Creator
Author

it do appears randomly..

where i always use the same set of data to generate the result

i have an idea, will it be possible that

after the button click action, the chart data is not ready after dimension selection is changed (data volume is quite large)

and so the fetch result is not correct?

Not applicable

So u can try by giving sleep command... by the time it will wait for that much time, your chart will get ready

laujerry
Creator
Creator
Author

that is just a guess...

i wonder if this situation will possibly happen or not