Why wont the Wildcard * work in this?

D

DawnTreader

Hello All

i have a bit of code that i am using trying to open a file. the code works for the most part, except when i put in a wildcard in the filename. when i do so it just opens "my documents".

here is the code:

Private Sub cmdOpenModel_Click()
Dim setFileName As String
Dim setPath As String

setPath = DLookup("VariableValue", "tblSystemVariables", "VariableName = 'ModelPathDefault'") '& "'"
setFileName = Me.SetNumber & "*.lxf"

MsgBox setPath & setFileName

If Dir(setPath & setFileName) <> "" Then
Shell Chr(34) & "EXPLORER.EXE" & Chr(34) & " " & setPath & setFileName & Chr(34), vbNormalFocus
Else
MsgBox "No Model available"
End If
End Sub

the *.lxf doesnt work, why? if i take it out it works fine. i need it to work with the wildcard so that it doesnt matter if the file name is longer than the number i pass to the code. i thought it was working yesterday, but it seems to have changed.

any and all help appreciated.
 
D

DawnTreader

Hello All

i have a bit of code that i am using trying to open a file. the code works for the most part, except when i put in a wildcard in the filename. when i do so it just opens "my documents".

here is the code:

Private Sub cmdOpenModel_Click()
Dim setFileName As String
Dim setPath As String

setPath = DLookup("VariableValue", "tblSystemVariables", "VariableName = 'ModelPathDefault'") '& "'"
setFileName = Me.SetNumber & "*.lxf"

MsgBox setPath & setFileName

If Dir(setPath & setFileName) <> "" Then
Shell Chr(34) & "EXPLORER.EXE" & Chr(34) & " " & setPath & setFileName & Chr(34), vbNormalFocus
Else
MsgBox "No Model available"
End If
End Sub

the *.lxf doesnt work, why? if i take it out it works fine. i need it to work with the wildcard so that it doesnt matter if the file name is longer than the number i pass to the code. i thought it was working yesterday, but it seems to have changed.

any and all help appreciated.

Ha. had my chr(34)'s in the wrong place. and not enough of them. kinda

Shell "EXPLORER.EXE" & Chr(34) & " " & setPath & setFileName & Chr(34), vbNormalFocus

the other problem was that it cant use a wild card when it actuall calls the file to open. it is better to find the file's name and then pass that to the shell.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top