Hur får jag ut sökvägen till filen, Delvis om jag vill använda den, bifoga den i outlook osv?
Set file = .... ger runtime error 13
Sub test()
Set oApp = GetOutlookApp
If oApp Is Nothing Then
MsgBox "Could not start Outlook.", vbInformation
Exit Sub
End If
strFileName = "Timereport_" & Excel.ActiveSheet.Name & ".pdf"
Set file = Excel.ActiveSheet.ExportAsFixedFormat(xlTypePDF, strFileName, xlQualityStandard, , , , , True)
End Sub
Lägger in all kod istället, jag lyckas alltså inte lägga till filen i outlook varken som file eller set file, med set file tidigare error, med file run-timer error 438
Function GetOutlookApp() As Outlook.Application
On Error Resume Next
Set GetOutlookApp = CreateObject("Outlook.Application")
End Function
Sub test()
Set oApp = GetOutlookApp
If oApp Is Nothing Then
MsgBox "Could not start Outlook.", vbInformation
Exit Sub
End If
strFileName = "Timereport_" & Excel.ActiveSheet.Name & ".pdf"
file = Excel.ActiveSheet.ExportAsFixedFormat(xlTypePDF, strFileName, xlQualityStandard, , , , , True)
Set objMail = CreateObject("Outlook.Application")
Set objClient = objMail.CreateItem(0)
With objClient
.Subject = Left(strFileName, Len(strFileName) - 4)
.Attachment = file
.Display
End With
End Sub
Spelnyheter från FZ
Copyright © 1999–2025 Geeks AB. Allt innehåll tillhör Geeks AB.
Citering är tillåten om källan anges.