ik krijg het helaas niet goed.
compileerfout: ByRef- Argumenttypen komen niet overeen.
bestand licht op
heb al heel wat geprobeerd
compileerfout: ByRef- Argumenttypen komen niet overeen.
bestand licht op
Code:
Sub BR_zoeken()
'bestand zoeken in c:\Documents\
' met de waarde uit dit bestand van blad2 cel G2
' en daarna dat bestand te openen
bestand = "C:\Documents\" & Range("Blad2!G2").Value & ".xls"
If Dir(bestand) = "" & Active Then
MsgBox ("Bestand niet gevonden: Probeer opnieuw")
Union([f7], [d7]).ClearContents
Exit Sub
End If
If IsFileOpen([COLOR="red"]bestand[/COLOR]) Then
MsgBox ("Bestand in gebruik")
Union([f7], [d7]).ClearContents
Exit Sub
End If
Set oudb = ActiveWorkbook
Set nieuwB = Workbooks.Open(bestand)
ActiveSheet.Unprotect Password:="pop"
nieuwB.ActiveSheet.Range("f7") = oudb.ActiveSheet.Range("f7")
Range("T4").Select
ActiveSheet.Protect Password:="pop"
With oudb.ActiveSheet
.Range("f7").ClearContents
.Range("d7").ClearContents
End With
oudb.Close SaveChanges:=True
Function IsFileOpen(strFullPathFileName As String) As Boolean
Dim hdlFile As Long
On Error GoTo FileIsOpen:
hdlFile = FreeFile
Open strFullPathFileName For Random Access Read Write Lock Read Write As hdlFile
IsFileOpen = False
Close hdlFile
Exit Function
FileIsOpen:
IsFileOpen = True
Close hdlFile
Function LastUser(path As String)
Dim text As String
Dim strFlag1 As String, strflag2 As String
Dim i As Integer, j As Integer
strFlag1 = Chr(0) & Chr(0)
strflag2 = Chr(32) & Chr(32)
Open path For Binary As #1
text = Space(LOF(1))
Get 1, , text
Close #1
j = InStr(1, text, strflag2)
i = InStrRev(text, strFlag1, j) + Len(strFlag1)
LastUser = Mid(text, i, j - i)
End Function
heb al heel wat geprobeerd