Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Support Cases coming to Qlik Community Oct. 4! Start chats, open cases, explore resources: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
lfalmoguera
Creator
Creator

Gather select field and use in macro

Hi all, 

first of all, thanks a lot in advance.

I have this macro to send an email and attach a file to it.

Sub Send()
Set objOL = CreateObject("Outlook.Application")
Set objMsg = objOL.CreateItem(olMailItem)
objMsg.Attachments.Add "c:\test\country_samplefile1.txt"
objMsg.subject = "Subject line"
objMsg.body = "Total amount is: sum(price)"
objMsg.to = "country@domain.com"
objMsg.Display
End sub

I have a field in QV which is country.

Depending in the value selected in country I want the macro to send the specific test file for that country,

For instance if I select Germany in the field country, I want the macro to send the file:

c:\test\Germany_samplefile1.txt

In addition, in the body of the email, I need the macro to get the value of sum(price).

How can I achieve this?

I have read about ActiveDocuments and all that, but I am quite lost.

Thanks a lot in advance.

Labels (4)
1 Solution

Accepted Solutions
rwunderlich

A simple approach for both is use the Evaluate() function. 

totalPrice = ActiveDocument.Evaluate("sum(price)")

country = ActiveDocument.Evaluate("only(country)")

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

View solution in original post

4 Replies
rwunderlich

A simple approach for both is use the Evaluate() function. 

totalPrice = ActiveDocument.Evaluate("sum(price)")

country = ActiveDocument.Evaluate("only(country)")

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

View solution in original post

Brett_Bleess
Support (Former)
Support (Former)

One other link, the QVW file that contains all the QlikView API calls, which may be helpful too:

https://help.qlik.com/en-US/qlikview-developer/April2020/Subsystems/Automation/Content/QV_Automation...

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
rwunderlich

By the way @Brett_Bleess , that API Guide link is for V10.  I posted that in a doc feedback a couple of years ago, but it's never been updated.  There is a V11 version floating around, but AFAIK there has never been a V12 published. Do you know if a V12 doc exists?

-Rob

Brett_Bleess
Support (Former)
Support (Former)

@rwunderlich Thanks, I am not sure how the heck I missed that, but I have flagged it to the Doc Team again, so hopefully they can verify latest release that contains all updates and get that in there instead.  I do not the APIs have been updated at all in the 12 tracks and as far as I am aware there are no plans to provide further updates either.  The APIs are as-is at this point.  In the 11.20 track, I believe the API Guide was included in the Full Documentation and Tutorial installer if I recall correctly, but I will let the Doc Team look into things at this point, thanks again for the flag on this.  

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.