Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with wildcard concatenation 2

Status
Not open for further replies.

chilly442

Technical User
Jun 25, 2008
151
US
I need to modify the following code to look up this file with a wildcard for the date, and if it exists, then open the ppt. Nothing that I have tried has worked.

Sub PlantFileExists()
Dim find
Dim file As String
file = "J:\ESD\Reports\Data\Plant\PlantPowerPoint10022008.ppt"
Set find = CreateObject("Scripting.FileSystemObject")
If Not find.FileExists(file) Then
MsgBox file & " was not located.", vbInformation, "File Not Found"
Else
MsgBox file & " has been located.", vbInformation, "File Found"
Presentations.Open FileName:="J:\ESD\Reports\Data\Plant\PlantPowerPoint10022008.ppt", ReadOnly:=msoFalse
End If
End Sub

Any help is always greatly appreciated!!!
...And worth a pretty star!
Thanks,
Chilly442
 
Is this what I am looking for?
It still says that it can't find the file.

Sub PlantFileExists()
Dim find
Dim file As String
file = Dir("J:\ESD\Reports\Data\Plant\PlantPowerPoint10072008.ppt")
Set find = CreateObject("Scripting.FileSystemObject")
If Not find.FileExists(file) Then
MsgBox file & " was not located.", vbInformation, "File Not Found"
Else
MsgBox file & " has been located.", vbInformation, "File Found"
Presentations.Open FileName:=Dir("J:\ESD\Reports\Data\Plant\PlantPowerPoint.ppt"), ReadOnly:=msoFalse
End If
End Sub
 
Dir returns "" if the file is not found.

file = Dir("J:\ESD\Reports\Data\Plant\PlantPowerPoint10072008.ppt")
if file <> "" then
'do your stuff
end if
 
file = Dir("J:\ESD\Reports\Data\Plant\PlantPowerPoint*.ppt")

file returns the name of the file "PlantPowerPoint10072008.ppt
Then it drops down and says that it can't find the file:"PlantPowerPoint10072008.ppt

I am still not sure what is going on?

Thanks in advance.
Chilly442
 
then it drops down to the msg box:

MsgBox file & " was not located.", vbInformation, "File Not Found"
Else
 
Untested

Code:
Sub PlantFileExists()

   Dim file As String
   file = "J:\ESD\Reports\Data\Plant\PlantPowerPoint10072008.ppt"
   If Dir(file)="" Then
      MsgBox file & " was not located.", vbInformation, "File Not Found"
   Else
      MsgBox file & " has been located.", vbInformation, "File Found"
      Presentations.Open FileName:=file, ReadOnly:=msoFalse
   End If
End Sub
 
A starting point:
Code:
path = "J:\ESD\Reports\Data\Plant\"
file = Dir(path & "PlantPowerPoint*.ppt")
If file <> "" Then file = path & file
...{/code]


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top