Originally Posted by
CBrine
Shazam,
Another option is using late binding, which is just a fancy way of saying change all your dll declarations to Object, and don't have a reference to the dll. Like this.
[vba]
Sub FindText()
Dim FSO As Object, f As Object, Path As String
Dim LastDate As Date, lastfile As String
Path = "C:\"
Set FSO = CreateObject("Scripting.FileSystemObject")
For Each f In FSO.GetFolder(path).Files
If f.Type = "Text Document" Then
If LastDate < f.DateLastModified Then
LastDate = f.DateLastModified
lastfile = f.Path
End If
End If
Next
Workbooks.OpenText lastfile
End Sub
[/vba]
I find the late binding is better when you are using functionality that has been available with the dll for a while.(Experience will tell you this). Actually referencing the object, lets you access to the intellisense drop downs, which can give you a good idea of what options are available to you.
Glad I could help. Don't forget to mark the thread solved.
Cal