Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
How i sent one graph from QV by e-mail with a macro?
Thank you
Regards
see this post
Re: export to excel and schedule mailing
here it is
Export and then send.
Below is sample Macro to export table called TB02 and send mail to the Email Address contains in EmailAddress Variable . which is working.
function ExcelFile
strDate = CDate(Date)
strDay = DatePart("d", strDate)
strMonth = DatePart("m", strDate)
strYear = DatePart("yyyy", strDate)
If strDay < 10 Then
strDay = "0" & strDay
End If
If strMonth < 10 Then
strMonth = "0" & strMonth
End If
GetFormattedDate = strMonth & "-" & strDay & "-" & strYear
Set v = ActiveDocument.Variables ("EmailAddress")
Email=v.GetContent.String
Path = "C:\EXCEL\OnRequest\"
FileName = "TESTCode_Data" & GetFormattedDate & ".xlsx"
set XLApp = CreateObject("Excel.Application")
XLApp.Visible = False
set XLDoc = XLApp.Workbooks.Add
ActiveDocument.GetSheetObject("TB02").CopyTableToClipboard true
XLDoc.Sheets(1).Paste()
XLDoc.Sheets(1).Columns("A:L").EntireColumn.AutoFit
XLDoc.Sheets(1).Columns("A:A").ColumnWidth = 17
XLDoc.Sheets(1).Columns("B:B").ColumnWidth = 17
XLDoc.Sheets(1).Columns("C:C").ColumnWidth = 17
XLDoc.Sheets(1).Columns("D:D").ColumnWidth = 17
XLDoc.Sheets(1).Columns("E:E").ColumnWidth = 17
XLDoc.Sheets(1).Columns("F:F").ColumnWidth = 17
XLDoc.Sheets(1).Columns("G:G").ColumnWidth = 17
XLDoc.Sheets(1).Columns("H:H").ColumnWidth = 17
XLDoc.Sheets(1).Columns("I:I").ColumnWidth = 17
XLDoc.Sheets(1).Columns("J:J").ColumnWidth = 17
XLDoc.Sheets(1).Columns("K:K").ColumnWidth = 17
XLDoc.Sheets(1).Columns("L:L").ColumnWidth = 17
XLDoc.Sheets(1).Name = "Export"
XLDoc.SaveAs Path & FileName
XLApp.Quit
Set myApp = CreateObject ("Outlook.Application")
Set myMessage = myApp.CreateItem(olMailItem)
myMessage.BodyFormat = 3 'Outlook.OlBodyFormat.olFormatRichText
myMessage.To = Email
myMessage.Attachments.Add "C:\EXCEL\OnRequest\" & FileName
myMessage.Subject = "TEST Codes Report " & Date()
myMessage.Body = "Hi Team, " & vbCrLf & "Please find the requested data for TEST Codes and let us know incase of any issues."
myMessage.Send
Set myMessage = Nothing
Set myApp = Nothing
Set myInspector = Nothing
Set myDoc = Nothing
end function