Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Not applicable

Macro: List box Value Selection and copying report to excel then mailing

Hi Guys,

I am trying to create a macro which selects a particular value of a field, copy the pivot chart to excel and mail it to particular recepients on a Tuesday every week.

I found success in copying the pivot chart to excel and mailing it by creating a button. Inside, in Actions tab selecting External and Run macro and editing the macro.

What i am unable to do is:

  • How to include conditions that select value of a field, in turn the chart modifies and then mailing it.
  • How to automate the process, so on a Tuesday when the data reloads, last week's summary is mailed to particular persons.
Tags (1)
1 Solution

Accepted Solutions
Not applicable

Re: Macro: List box Value Selection and copying report to excel then mailing

Thanks Gysbert,

If  DatePart("w",Date()) = 3 then

    'do tuesday stuff

Else

    'do other days stuff

End if

If ActiveDocument.Fields("Month").Select("September") then

     'September was selected, do the september stuff

Else

     'September could not be selected, do the other stuff

End if

9 Replies

Re: Macro: List box Value Selection and copying report to excel then mailing

It's probably easier to create a bookmark instead and activite the bookmark with a OnPostReload trigger.


talk is cheap, supply exceeds demand
Not applicable

Re: Macro: List box Value Selection and copying report to excel then mailing

But can we create dynamic bookmarks in qlikview, since i wanted last weeks data to be sent via mail.

Re: Macro: List box Value Selection and copying report to excel then mailing

Yes, that's possible. I think these threads can help you:

http://community.qlik.com/thread/31454

http://community.qlik.com/thread/30095

I hope this helps


talk is cheap, supply exceeds demand
Not applicable

Re: Macro: List box Value Selection and copying report to excel then mailing

Hi Gysbert,

Thanks for all your advice, I can now create dynamic bookmarks.

There are two things I want to do now

  1. Check if the day is a "tue".
  2. Check if a particular value of a field is present ...if yes..select the value and do .....if no do.....

                All this i prefer to write in a macro. Can anyone hardcode it for me.

Re: Macro: List box Value Selection and copying report to excel then mailing

If  DatePart("w",Date()) = 3 then

    'do tuesday stuff

Else

    'do other days stuff

End if

If ActiveDocument.Fields("Month").Select "September" then

     'September was selected, do the september stuff

Else

     'September could not be selected, do the other stuff

End if


talk is cheap, supply exceeds demand
Not applicable

Re: Macro: List box Value Selection and copying report to excel then mailing

I follow this and it gives me   Expected'Then'    kind of error.

Re: Macro: List box Value Selection and copying report to excel then mailing

HI

Try like this

s = ActiveDocument.Evaluate("GetFieldSelections(Month)")

if s = 'September' then

'do something

else

'do something

end if

Edit:

Sorry,  i misunderstand the concept..

Hope it helps

Re: Macro: List box Value Selection and copying report to excel then mailing

ActiveDocument.Fields("Month").Select("September") does not do what I expect (at least not in QV10, maybe in QV11 it does work). You'll need something like this instead

flag=0

ActiveDocument.Fields("Month").Select("September")

set val=ActiveDocument.Fields("Month").GetSelectedValues

for i=0 to val.Count-1

    if val.Item(i).text = "September" then

       flag=1    

    end if

next

if flag=1 then

     'September was selected, do the september stuff

Else

     'September could not be selected, do the other stuff

End if


talk is cheap, supply exceeds demand
Not applicable

Re: Macro: List box Value Selection and copying report to excel then mailing

Thanks Gysbert,

If  DatePart("w",Date()) = 3 then

    'do tuesday stuff

Else

    'do other days stuff

End if

If ActiveDocument.Fields("Month").Select("September") then

     'September was selected, do the september stuff

Else

     'September could not be selected, do the other stuff

End if

Community Browser