Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to add user email to existing macro?


Hi,

I have the below macro which will send the data to excel. How can I add the user email id so that when my user click on button directly the excel file should go to user email

Can anyone suggest me please.

Sub xl

set XLApp = CreateObject("Excel.Application")

XLApp.Visible=True

set XLDoc = XLApp.Workbooks.Add

set table = ActiveDocument.GetSheetObject("TB01")

set XLSheet = XLDoc.Worksheets("Sheet1")

table.CopyTableToClipboard true

XLSheet.Paste XLSheet.Range( "A1")

End Sub

Thanks.

EDIT: I need the below lines also in the macro

objEmail.From = "QlikView@Reporting"                        'Email Sender

    objEmail.Subject = "Dashboard"                        ' Subject

That is when my user click the button the from address should be Qlikview@Reporting.

4 Replies
Not applicable
Author

Can anyone suggest me please?

Not applicable
Author

Please suggest whether is it possible to get this?

Not applicable
Author

hi Amelia,

change the pdf extention to ur excel file extention and enter ur file path to excel file like "D:\foldername\filename.xlsx". hope this will help you

sub Email()

Dim OutApp

    Dim OutMail

    dim emailadd

     SET fx = ActiveDocument.Fields("Email_address")

Set OutApp = CreateObject("Outlook.Application")

    set v = ActiveDocument.Variables("v")

    set b=ActiveDocument.Variables("b")

  ' Set objSelected =ActiveDocument.Fields("VEmail").GetSelectedValues

  

    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next

  

    With OutMail

       

        .To="ur-email@domain.com"

        .CC = ""

        .BCC = ""

        .Subject = (v.GetContent().String)

        .Body = (b.GetContent().String)

        .Attachments.Add ActiveWorkbook.FullName

        'msgbox (v.GetContent().String&n.GetContent().String &".pdf"  )

       

        .Attachments.Add ("ur folder path to excel" )

       

        .Send  

       ' msgbox"Msg Sent"

        activate=0

        emailadd=""

    End With

    On Error GoTo 0

    Set OutMail = Nothing

    Set OutApp = Nothing

   

end sub

Not applicable
Author

Thanks. Do I need SMTP sever details when I used this in server instead of Qlikview personal edition?