all you code must be within the procedure
Code:
_________________________________________________________ (strange grey line)
Sub SaveAllAttachments(objitem As MailItem)
Dim objAttachments As Outlook.Attachments
Dim strName, strLocation As String
Dim dblCount, dblLoop As Double
MsgBox strName ' should be empty messagebox as strname is empty at this point
strLocation = "K:\Ny mappe struktur\Servicemarked\Volkswagen og Audi verksted\Gjennomganger - Teksteark\Jack\"
On Error GoTo ExitSub
If objitem.Class = olMail Then
Set objAttachments = objitem.Attachments
dblCount = objAttachments.Count
If dblCount <= 0 Then
End If ' put breakpoint on next line, then step through code to see if it enters loop
For dblLoop = 1 To dblCount
strName = strLocation & Replace(Mid(objitem.Subject, 13, Len(fn) - 25), "/", " ") & ".pdf"
MsgBox strName ' just to see it the path\filename lloks like it is correct
objAttachments.Item(dblLoop).SaveAsFile strName
Next dblLoop
'objitem.Delete
End If
100
ExitSub:
Set objAttachments = Nothing
Set objOutlook = Nothing
End Sub