Private Sub cmdEmail_Click()
Dim oRange As Range
Dim oCht As Chart
Dim oImg As Picture
Set oRange = Range("A1:P40")
Set oCht = Charts.Add
oRange.CopyPicture xlScreen, xlPicture
oCht.Paste
oCht.Export Filename:="C:\Temp\SavedRange.jpg", Filtername:="JPG"
Screenshot_Mail "Sample Email Address" & "; " & "Sample Email Address", "Sample Email Address" & _
"; " & "Sample Email Address" & "; " & "Sample Email Address", "Rep II Case Productivity Report", "<font color=red>" & _
"<I>" & "Below is a Snapshot View of the Rep II Case Productivity Report: " & "</font>" & "</I>" & _
"<BR>" & "<BR>" & "<BODY><FONT face=Arial color=#000080 size=2></FONT>" & _
"<IMG alt='' hspace=0 src='C:\Temp\SavedRange.jpg' align=baseline border=0> </BODY>"
DoEvents
oCht.Delete
End Sub
Sample-Workbook.xlsm
ASKER
Private Sub cmdEmail_Click()
Dim oRange As Range
Dim oCht As Chart
Dim oImg As Picture
Dim iGetRows As Integer
Dim strRange As String
iGetRows = Worksheets("Printable_Version").Cells.Find("*", _
Worksheets("Printable_Version").Cells(1), xlFormulas, _
xlWhole, xlByRows, xlPrevious).Row
strRange = "A1:P" & CStr(iGetRows + 25)
Set oCht = Charts.Add
DoEvents
Call AdjustChart
Set oRange = Range(strRange)
oRange.CopyPicture xlScreen, xlPicture
oCht.Paste
oCht.Export Filename:="C:\Temp\SavedRange.jpg", Filtername:="JPG"
Screenshot_Mail "Sample Email Address" & "; " & "Sample Email Address", "Sample Email Address" & _
"; " & "Sample Email Address" & "; " & "Sample Email Address", "Rep II Case Productivity Report", "<font color=red>" & _
"<I>" & "Below is a Snapshot View of the Rep II Case Productivity Report: " & "</font>" & "</I>" & _
"<BR>" & "<BR>" & "<BODY><FONT face=Arial color=#000080 size=2></FONT>" & _
"<IMG alt='' hspace=0 src='C:\Temp\SavedRange.jpg' align=baseline border=0> </BODY>"
DoEvents
oCht.Delete
End Sub
Public Sub AdjustChart()
Dim oChtObj As ChartObject
Dim oRng As Range
Dim iGetRows As Integer
Dim strRange As String
iGetRows = Worksheets("Printable_Version").Cells.Find("*", _
Worksheets("Printable_Version").Cells(1), xlFormulas, _
xlWhole, xlByRows, xlPrevious).Row
strRange = "A" & CStr(iGetRows + 2) & ":P" & CStr(iGetRows + 25)
Worksheets("Printable_Version").Activate
ActiveSheet.ChartObjects("Chart 3").Activate
Set oChtObj = ActiveChart.Parent
Set oRng = ActiveSheet.Range(strRange)
oChtObj.Left = oRng.Left
oChtObj.Width = oRng.Width
oChtObj.Top = oRng.Top
oChtObj.Height = oRng.Height
Set oChtObj = Nothing
Set oRng = Nothing
End Sub
ASKER
ASKER
ASKER
Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.
TRUSTED BY