Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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.
1 Solution

Accepted Solutions
Not applicable
Author

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

View solution in original post

9 Replies
Gysbert_Wassenaar

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
Author

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

Gysbert_Wassenaar

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
Author

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.

Gysbert_Wassenaar

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
Author

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

MayilVahanan

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

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Gysbert_Wassenaar

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
Author

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