Author Topic: findfile without dialogbox  (Read 3710 times)

0 Members and 1 Guest are viewing this topic.

Amsterdammed

  • Guest
findfile without dialogbox
« on: June 03, 2005, 12:56:55 PM »
Does in VBA something like findfile in Lisp exist or does it always open the dialog? :?:

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
findfile without dialogbox
« Reply #1 on: June 03, 2005, 01:26:31 PM »
You can use something like this:

Code: [Select]

Dim filenamewithpath As String
Dim filename As String
filenamewithpath = "C:\Program Files\ACAD2006\SomelispFile.lsp"
filename = Dir(filenamewithpath)
If filename = "" Then
 MsgBox "File does not exist"
End If
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Amsterdammed

  • Guest
findfile without dialogbox
« Reply #2 on: June 03, 2005, 02:06:33 PM »
I understand this.

My Problem is that I work for company with offices in different towns, every office is run by different IT clowns with different working methodes. So I don't know the locations where my code must find a certain file. In lisp i would let it search with findfile  for my mnl file and than I know the location where my stuff is parked.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
findfile without dialogbox
« Reply #3 on: June 03, 2005, 04:06:25 PM »
I think what you are looking for is an implementation of FindFirstFile and FindNextFile API calls that will work in VBA. Go to this page, type findfirst into the Search for box and then press [Search VBNet].

Example1; example2.

/perhaps
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Amsterdammed

  • Guest
findfile without dialogbox
« Reply #4 on: June 18, 2005, 09:54:11 AM »
I found this on the web, posted by Bob Wahr in 2003

Code: [Select]

Private Function FindFile(strFile As String)
Dim strSupPth As String
Dim varPaths As Variant
Dim intCnt As Integer
Dim strFnd As String
Dim strTest As String
Dim strDwgDir As String

strSupPth = ThisDrawing.GetVariable("acadprefix")
strDwgDir = ThisDrawing.GetVariable("dwgprefix")
strTest = Dir(CurDir & "\" & strFile, 31)
If strTest <> "" Then
strFnd = CurDir & "\" & strTest
Else
strTest = Dir(strDwgDir & "\" & strFile, 31)
If strTest <> "" Then
strFnd = strDwgDir & "\" & strFile
Else
If strSupPth <> "" Then
varPaths = Split(strSupPth, ";", -1, vbTextCompare)
For intCnt = 0 To UBound(varPaths)
strTest = Dir(varPaths(intCnt) & "\" & strFile, 31)
If strTest <> "" Then
strFnd = varPaths(intCnt) & "\" & strFile
Exit For
End If
Next intCnt
End If
End If
End If

FindFile = strFnd

End Function