sspatriots
Well-known Member
- Joined
- Nov 22, 2011
- Messages
- 585
- Office Version
- 365
- Platform
- Windows
I have this code below that sizes up my userform nicely and temporarily places it in a network folder so it can be grabbed and displayed in an e-mail. Now, I'm being asked to do the same thing, except attach the a .pdf of that .jpg file to an email as an attachment. I was hoping it would be as simple as changing the extension in the code below, but no luck there. Any help would be greatly appreciated. Thanks, SS
I also have the code below that will print the same userform to a printer and size it correctly. Wasn't sure if it would be better to try and modify it to make it print to a pdf and then have another macro that grabs that file off of the network and attaches it to an e-mail.
VBA Code:
Sub EmailWithPicture()
Dim ol As Outlook.Application
Dim mi As Outlook.MailItem
Dim doc As Word.Document
Dim shp As Word.InlineShape
Set ol = New Outlook.Application
Set mi = ol.CreateItem(olMailItem)
mi.Display
'mi.To = "someone@somewhere.com"
mi.Subject = "Job Status: " & Sheets("Quick Search Job Status").Range("B3").Value 'txtJobName.Text'"Pictures"
Set doc = mi.GetInspector.WordEditor
Set shp = doc.Range(0, 0).InlineShapes.AddPicture("\\Documents\PROJECTS\Job List\Test.jpg")
shp.LockAspectRatio = msoTrue
shp.Width = 600
shp.Glow.Color.RGB = RGB(255, 0, 0)
shp.Glow.Radius = 10
shp.Glow.Transparency = 0.5
'shp.Reflection.Type = msoReflectionType3
shp.Borders.OutsideLineStyle = wdLineStyleDashDot
shp.Borders.OutsideLineWidth = wdLineWidth225pt
'doc.Range(0, 0).InsertBefore _
' "Please find the current Job Status below:" & vbNewLine & vbNewLine & "" & vbNewLine & vbNewLine
End Sub
I also have the code below that will print the same userform to a printer and size it correctly. Wasn't sure if it would be better to try and modify it to make it print to a pdf and then have another macro that grabs that file off of the network and attaches it to an e-mail.
VBA Code:
Sub PrintJobStatus()
Dim sShape As Picture
Set sShape = Worksheets("Temp").Pictures.Insert("\\Documents\PROJECTS\Job List\Test.jpg")
With sShape
.ShapeRange.LockAspectRatio = msoTrue '<---- Lock the original width/height ratio
.Left = 0 '<---- Very left of sheet
.Top = 0 '<---- Very top of sheet
.Width = Columns(24).Left '<---- 9 Columns wide
.Name = "Picture 1"
End With
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
.LeftMargin = Application.CentimetersToPoints(2#)
.RightMargin = Application.CentimetersToPoints(0.5)
.TopMargin = Application.CentimetersToPoints(1.5)
.BottomMargin = Application.CentimetersToPoints(0.5)
.HeaderMargin = Application.CentimetersToPoints(0.2)
.FooterMargin = Application.CentimetersToPoints(0.2)
.PaperSize = xlPaperLetter
.Orientation = xlPortrait 'xlLandscape
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
ActiveSheet.Range("A1:W72").PrintOut
'ActiveSheet.Range("A1:W45").PrintPreview
'or 'ActiveSheet.Cells(1, 1).Resize(ActiveSheet.Shapes("Picture 1").BottomRightCell.Row, ActiveSheet.Shapes("Picture 1").BottomRightCell.Column).PrintOut
'or 'ActiveSheet.Cells(1, 1).Resize(ActiveSheet.Shapes("Picture 1").BottomRightCell.Row, ActiveSheet.Shapes("Picture 1").BottomRightCell.Column).PrintPreview
End Sub