determine extension

June 21st, 2012 - 08:41 am ET by susan | Report spam
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
email Follow the discussionReplies 2 repliesReplies Make a reply

Similar topics

Replies

#1 Bob Quintal
June 21st, 2012 - 05:26 pm ET | Report spam
"susan" wrote in
news:71605$4fe31665$524a97be$:

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
Bob Q.
PA is y I've altered my address.
Replies Reply to this message
#2 Douglas J Steele
June 21st, 2012 - 05:31 pm ET | Report spam
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
news:71605$4fe31665$524a97be$

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
email Follow the discussion Replies Reply to this message
Help Create a new topicReplies Make a reply
Search Make your own search