Sub Klantrapport()
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False
Dim Matnr As String
Dim Batchnr As String
Dim batchvolg As String
Dim Partname As String
Dim Year As String
Dim Awb As String 'Hexagon
Dim Nwb As String
Dim HMF As String 'Hexagon moederfile
Dim Temp As String 'excel template
Dim WTemp As Workbook
Dim Macro As String
'Huidige werkbook wordt Awb en definitie batch, materiaal nrs
Awb = ActiveWorkbook.Name
batchvolg = Range("C12")
Partname = Range("C3")
Matnr = Left(Range("C3").Value, 8)
Batchnr = Left(Range("C12").Value, 12)
Year = Right(Range("C8").Value, 4)
Filename = "J:\Kwaliteit Helmond\Hexagon\Optiv_3\" & Matnr & "_ep.xls"
Workbooks.Open Filename
HMF:
Nwb = ActiveWorkbook.Name
Workbooks(Awb).Activate
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Workbooks(Nwb).Activate
Sheets("Hexagon").Select
Cells.Select
ActiveSheet.Paste
'Autofit en hiden kolommen die niet gebruikt worden
'Range("A:A,E:E,F:F,K:K,N:N,O:O,P:P,Q:Q,R:R,S:S,T:T,U:U,V:V").Select
'Range("V1").Activate
'Selection.EntireColumn.Hidden = True
Columns("B:B").EntireColumn.AutoFit
'Columns("C:C").EntireColumn.AutoFit
'Columns("D:D").EntireColumn.AutoFit
Columns("E:E").EntireColumn.AutoFit
Columns("F:F").EntireColumn.AutoFit
Columns("G:G").EntireColumn.AutoFit
Columns("H:H").EntireColumn.AutoFit
Columns("I:I").EntireColumn.AutoFit
Columns("J:J").EntireColumn.AutoFit
Columns("G:G").EntireColumn.AutoFit
Columns("L:L").EntireColumn.AutoFit
Columns("M:M").EntireColumn.AutoFit
Columns("N:N").EntireColumn.AutoFit
Columns("O:O").EntireColumn.AutoFit
Columns("P:P").EntireColumn.AutoFit
Columns("Q:Q").EntireColumn.AutoFit
Columns("R:R").EntireColumn.AutoFit
Range("A1").Select
Application.CutCopyMode = False
Workbooks(Awb).Activate
Range("A1").Select
ActiveWorkbook.Close
Workbooks(Nwb).Activate
FilePath = ""
On Error Resume Next
FilePath = Dir("J:\Kwaliteit Helmond\FINAL INSPECTION REPORTS\" & Year & "\" & Matnr & "\")
On Error GoTo 0
If FilePath = "" Then
MkDir "J:\Kwaliteit Helmond\FINAL INSPECTION REPORTS\" & Year & "\" & Matnr & "\"
End If
ActiveWorkbook.SaveAs "J:\Kwaliteit Helmond\FINAL INSPECTION REPORTS\" & Year & "\" & Matnr & "\" & Partname & "_" & batchvolg & ".xls", FileFormat:=xlNormal
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = True
End Sub