determine extension

S

susan

Hi,

I want to open a file with the

Private Sub Command1_Click()
Application.FollowHyperlink (Myfile)
End Sub


- I do know the foldermame Infile is in
- I do know the name of Infile
- I do not know the extension of Infile

So: Myfile = Foldername & "\" & Filename & "." & Extension

How can I determine the extension of the file, knowing that each file
excists only once in the folder.
Ext = "*" or Ext = "???" does not work.

Thanks,

Susan
 
B

Bob Quintal

Hi,

I want to open a file with the

Private Sub Command1_Click()
Application.FollowHyperlink (Myfile)
End Sub


- I do know the foldermame Infile is in
- I do know the name of Infile
- I do not know the extension of Infile

So: Myfile = Foldername & "\" & Filename & "." & Extension

How can I determine the extension of the file, knowing that each
file excists only once in the folder.
Ext = "*" or Ext = "???" does not work.

Thanks,

Susan

the Dir statement will return all files that meet the applied mask.
so that
Foldername = "C:\Windows"
Filename = "Zapotec"
Myfile = dir(Foldername & "\" & Filename & ".*")
'myfile now contains: Zapotec.bmp
Myfile = Foldername & "\" & Myfile
' now holds: C:\Windows\Zapotec.bmp
 
D

Douglas J Steele

How are you determining the values of Filename and Foldername?

Try:

strFileName = Dir(Foldername & "\" & Filename & ".*")
strExtension = Mid(strFileName, InStrRev(strFileName, ".") + 1)

"susan" wrote in message

Hi,

I want to open a file with the

Private Sub Command1_Click()
Application.FollowHyperlink (Myfile)
End Sub


- I do know the foldermame Infile is in
- I do know the name of Infile
- I do not know the extension of Infile

So: Myfile = Foldername & "\" & Filename & "." & Extension

How can I determine the extension of the file, knowing that each file
excists only once in the folder.
Ext = "*" or Ext = "???" does not work.

Thanks,

Susan
 

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