Adding .doc extension to text file

Z

zSplash

I am trying to add ".doc" extension to text files (that have no extension),
but I'm missing the boat. All the files in C:\TextFiles need the extension.
I have unsuccessfully tried this:
Sub renameFiles()
Dim sDir As String, sFilename As String
sFilename = Dir("C:\TextFiles\*.*")
sDir = "C:\TextFiles\*.*"
Do While sFilename <> ""
Name sDir + sFilename As sDir + sFilename + ".doc"
'get to next file
sFilename = Dir()
Loop
End Sub
and this:
Sub renameFiles2()
Dim lsFileName, thePath As String
lsFileName = Dir("C:\TextFiles\*.*")
thePath = "C:\TextFiles\"
Do While lsFileName <> ""
'add extension to filename
lsFileName = FileName & ".doc"
lsFileName = Dir()
Loop
End Sub

Will someone please (re)direct me/help?

TIA
 
Z

zSplash

Got it, guys. Thanks anyway. (Ain't VBA grand?!)

Sub addDocExtensions()
Dim sDir As String, lsName As String, sFilename As String
sDir = "C:\TextFiles\"
lsName = Dir("C:\TextFiles\*.*")
Do While lsName <> ""
sFilename = lsName & ".doc"
Name sDir + lsName As sDir + sFilename
lsName = Dir()
Loop
End Sub

st.
 

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