Centar za edukaciju-BiH



#1 19.01.2021-21:32
nevsad Offline
Clan
Registrovan/a od: 01.09.2010-14:40
Komentari: 208


Subject: Application.FileSearch
Dim fs
Set fs = Application.FileSearch
With fs
.LookIn = "C:\windows"
.FileName = "print.txt"

If .Execute > 0 Then
'coddd...
End If
End With
ovaj kod funkcionira u 2003
šta je zajenaa za FileSearch u 2007
unaprijed hvala
↑  ↓

#2 20.01.2021-09:55
Gjoreski Offline
Super Moderator
Registrovan/a od: 02.02.2009-22:24
Komentari: 1,754


Subject: Re: Application.FileSearch
Kod je isti i za 2007 samo verovatno nisu ti reference ucitane isto kao i u 2003
↑  ↓

#3 20.01.2021-10:38
zxz Offline
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 10,331


Subject: Re: Application.FileSearch
Imas u arhivi zamjenu odnosno vb funkcij
https://icentar.ba/...t&id=7179

DownloadIzvorni kod (Visual Basic):
  1. Function DirFajl(Putanja As String, Optional Kriterija As String = "*")
  2. On Error GoTo Error_Handler
  3.     Dim Fajl As String
  4.  
  5.     Fajl = Dir(Putanja & "*." & Kriterija)
  6.         Do While Fajl <> vbNullString
  7.             If Fajl <> "." And Fajl <> ".." Then
  8.                     Debug.Print "- " & Fajl
  9.             End If
  10.             Fajl = Dir
  11.         Loop
  12.  
  13. Error_Handler_Exit:
  14.     On Error Resume Next
  15.     Exit Function
  16.  
  17. Error_Handler:
  18.     MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
  19.             "Error Number: " & Err.Number & vbCrLf & _
  20.             "Error Source: DirFajl" & vbCrLf & _
  21.             "Error Description: " & Err.Description, _
  22.             vbCritical, "An Error has Occured!"
  23.     Resume Error_Handler_Exit
  24. End Function

Pozdrav
↑  ↓

#4 20.01.2021-12:41
nevsad Offline
Clan
Registrovan/a od: 01.09.2010-14:40
Komentari: 208


Subject: Re: Application.FileSearch
koja tacno referenca mora biti zakacena

hvala
↑  ↓

#5 20.01.2021-21:57
zxz Offline
Administrator
Registrovan/a od: 03.02.2009-16:22
Komentari: 10,331


Subject: Re: Application.FileSearch
Na osnovu onoga sto si dao tebi treba da provjeris dali fajl postoji u nekom dir.
Ako sam u pravu evo rjesenje.
Ovu funkciju stavi u neki modul.
DownloadIzvorni kod (Visual Basic):
  1. Function FileExists(Putanja As String, Optional ImeFajla As String) As Boolean
  2. On Error GoTo Error_Handler
  3. Dim Fajl As String, PathStr As String
  4.  
  5.  If Right(Putanja, 1) = "/" Or Right(Putanja, 1) = "\" Then
  6.  PathStr = Putanja & ImeFajla
  7.  Else
  8.   PathStr = Putanja & "/" & ImeFajla
  9.  End If
  10.         If Dir(PathStr) <> "" Then
  11.            FileExists = True
  12.            Exit Function
  13.         End If
  14.  
  15. Error_Handler_Exit:
  16.     On Error Resume Next
  17.     FileExists = False
  18.     Exit Function
  19.  
  20. Error_Handler:
  21.     MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
  22.             "Error Number: " & Err.Number & vbCrLf & _
  23.             "Error Source: DirFajl" & vbCrLf & _
  24.             "Error Description: " & Err.Description, _
  25.             vbCritical, "An Error has Occured!"
  26.     Resume Error_Handler_Exit
  27. End Function

funkciju pozivas:
Dim a as boolean
a=FileExists("d:/temp","SYS.MDW")
Vraca true ako ima a false ako nema fajla
Pozdrav
↑  ↓

#6 21.01.2021-00:18
nevsad Offline
Clan
Registrovan/a od: 01.09.2010-14:40
Komentari: 208


Subject: Re: Application.FileSearch
to je to...
na open forme, loga, provjeri da li postoji neki fajl
pa ide dalje ili izlazi
ova konamda ne postoji u 2007
dosta stvari korisnih ima na
https://www.access-programmers.co.uk/
fino hvala
jos uvijek nisam siguran da cu pobjeci od 2003
exsperimentiram sa 2007
...
↑  ↓

Stranice (1): 1


All times are GMT +01:00. Current time: 15.04.2021-14:54.