Public telleraanwezig As Boolean
Function IsFileOpen(filename As String)
Dim filenum As Integer, errnum As Integer
On Error Resume Next ' Turn error checking off.
filenum = FreeFile() ' Get a free file number.
' Attempt to open the file and lock it.
Open filename For Input Lock Read As #filenum
Close filenum ' Close the file.
errnum = Err ' Save the error number that occurred.
On Error GoTo 0 ' Turn error checking back on.
'Check to see which error occurred.
Select Case errnum
' No error occurred.
' File is NOT already open by another user.
Case 0
IsFileOpen = False
' Error number for "Permission Denied."
' File is already opened by another user.
Case 70
IsFileOpen = True
' Another error occurred.
Case Else
Error errnum
End Select
End Function
Sub fileopen()
If IsFileOpen("G:\path and file name.xls") Then
MsgBox "De database is in gebruik. Gelieve deze eerst te sluiten"
ActiveWindow.Close
End If
End Sub
Sub invoer()
'zorgt ervoor dat de compatibiliteitsmodus niet opkomt
Application.DisplayAlerts = False
telleraanwezig = False
'opslaan en opslaan als zit geblokkeerd in thisworkbook
'
' invoer Macro
'
If IsFileOpen("path and file name 2") Then
MsgBox "De database is in gebruik. Gelieve deze eerst te sluiten"
ActiveWindow.Close
End If
Workbooks.Open filename:="path and file name"
Rows("5:5").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Rows("8:8").Select
Selection.Copy
Rows("5:7").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("A8").Select
Selection.AutoFill Destination:=Range("A5:A8"), Type:=xlFillDefault
Range("A5:A8").Select
Windows("invoeren storingsanalyse.xlsm").Activate
Range("F10").Select
Selection.Copy
Windows("Database storingsanalyses.xls").Activate
Range("L5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("invoeren storingsanalyse.xlsm").Activate
Range("B6").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Database storingsanalyses.xls").Activate
Range("C5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("invoeren storingsanalyse.xlsm").Activate
Range("B5").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Database storingsanalyses.xls").Activate
Range("H5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("invoeren storingsanalyse.xlsm").Activate
Range("A13:E13").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Database storingsanalyses.xls").Activate
Range("I5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("invoeren storingsanalyse.xlsm").Activate
Range("H5").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Database storingsanalyses.xls").Activate
Range("E5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("invoeren storingsanalyse.xlsm").Activate
Range("H6").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Database storingsanalyses.xls").Activate
Range("F5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
' Windows("invoeren storingsanalyse.xlsm").Activate
'Range("H7").Select
'Application.CutCopyMode = False
'Selection.Copy
Windows("Database storingsanalyses.xls").Activate
Range("K5").Select
ActiveCell.FormulaR1C1 = "Nog te bekijken"
'Range("K5").Select
'Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
Windows("invoeren storingsanalyse.xlsm").Activate
Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Database storingsanalyses.xls").Activate
Range("B5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Dim Path As String
Dim FileName1 As String
' Dim FileName2 As String
Dim file As String
Windows("invoeren storingsanalyse.xlsm").Activate
DATES = Format(Range("B6"), "dd-mm-yyyy")
Path = "file path here"
FileName1 = Range("B5")
file = "SA-" & FileName1 & "-" & DATES & ".xls"
Windows("Database storingsanalyses.xls").Activate
Range("J5").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, _
Address:="file path" & file, _
TextToDisplay:="Link", _
SubAddress:="" & CStr(LRowC), _
ScreenTip:="" & CStr(LRowC)
Range("P5").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("P5:P7"), Type:=xlFillDefault
Range("P5:P7").Select
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveSheet.Range("$A$4:$L$1111").AutoFilter Field:=9, Criteria1:="="
Rows("6:1113").Select
Range("F7").Activate
Selection.Delete Shift:=xlUp
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
ActiveSheet.Range("$A$4:$L$1110").AutoFilter Field:=9
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
ActiveWindow.SmallScroll Down:=-9
Range("A1:L3").Select
telleraanwezig = True
ActiveWorkbook.Save
ActiveWindow.Close
telleraanwezig = False
'Doorsturen knop verwijderen voor het als nieuw bestand wordt opgeslaan
ActiveSheet.Shapes("Doorsturen").Delete
'Slaat het bestand op als
telleraanwezig = True
ActiveWorkbook.SaveAs filename:=Path & "SA-" & FileName1 & "-" & DATES & FileExtStr = ".xls": FileFormatNum = 56
telleraanwezig = False
'Slaat het bestand op
telleraanwezig = True
ActiveWorkbook.Save
telleraanwezig = False
'Print de file in het lokaal van LVC, maar zet daarna de standaardprinter terug
Dim STDprinter As String
STDprinter = Application.ActivePrinter
ActiveSheet.PrintOut ActivePrinter:="\\SRPGEN23055\PR251419"
Application.ActivePrinter = STDprinter
'Opent outlook en verzend het invoer bestand
With CreateObject("Outlook.Application")
x = .GetNamespace("MAPI").GetDefaultFolder(6).Items.Count
End With
With CreateObject("Outlook.Application").createitem(0)
.to = "somepeople@someplace.com"
.Subject = "Storingsanalyse Processing " & Range("B5")
.attachments.Add "file path" & file
.Send
Range("A1").Value = Range("A1").Value + 1
ActiveWindow.Close
End With
End Sub