Sweedler
Board Regular
- Joined
- Nov 13, 2020
- Messages
- 132
- Office Version
- 365
- Platform
- Windows
Hello
I am using the following code to try to achieve this, but I am running into error issues. I have made the error area in bold text. I am hoping that someone can help me.
The PDF export works flawlessly, but I the export to email is not working.
Hoping that you can help me,
Cheers
I am using the following code to try to achieve this, but I am running into error issues. I have made the error area in bold text. I am hoping that someone can help me.
Rich (BB code):
Sub Indi_SV_generator()
Dim OutApp As Object
Dim Outmail As Object
Set OutApp = CreateObject("outlook.application")
Set Outmail = OutApp.CreateItem(0)
Dim bolaget As String
Dim plats As String
Dim namn As String
Dim year As Integer
Dim month As Integer
Dim day As Integer
Dim i As Integer
Dim a As Integer
Dim filename As Range
Dim savelocation As String
bolaget = Sheet6.Range("K1")
plats = Sheet6.Range("K2")
year = Sheet6.Range("K4")
month = Sheet6.Range("K5")
day = Sheet6.Range("K6")
a = Sheet6.Range("K7")
For i = a To 2 Step -1
namn = Sheet6.Cells(i, 1)
Sheet6.Range("K8") = Sheet6.Cells(i, 1)
Set filename = Sheet4.Range("A1")
savelocation = "C:\Users\marcu\Desktop\EXCELLENT HELP - PC\Customers\Moll Wenden\Test folder\ " & "Individuellt - " & namn & " - " & year & "-" & month & "-" & day
Sheets("INDI SV").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
filename:=savelocation
With Outmail
.to = Sheet6.Cells(i, 2)
.Subject = "RÄTTNING"
.Body = "vänligen se bifogad fil"
.attachments.Add (savelocation & ".pdf")
.display
End With
Next i
End Sub
The PDF export works flawlessly, but I the export to email is not working.
Hoping that you can help me,
Cheers
Last edited by a moderator: