I have not used VB for this before. I guess it's possible, but is there a property / method for renaming a file (I need it for the extension part really) - ie; rename file.doc to file.xls.
Thank you
Printable View
I have not used VB for this before. I guess it's possible, but is there a property / method for renaming a file (I need it for the extension part really) - ie; rename file.doc to file.xls.
Thank you
Try the Name command.
Hope this helps.Code:Name oldpathname As newpathname
Michael
Try
you can change Left(yourOldFile,len(youOldFile)-4) byCode:shell "Rename " & yourOldFile & " " & Left(yourOldFile,len(youOldFile)-4) & ".xls"
your function if you want,it's just to put your file
without the extention.
Or you just can use
FileCopy yourOldFile,yourNewFile
Kill yourOldFile
ahhhhhh, thank you for that one, I was looking at change name, alter, ren, rename, everything but :D
Yeah I agree with Michael, use NAME, but be sure to include the whole directory with it:
Have fun!Code:Name "c:\mypath\myfile.ext" As "c:\mypath\myfile\mynewfile.ext"
so you can also use it to Move files.
Name "c:\file" As "c:\jop\file"
Remeber, by changing the extension of a file you are not changing the type of the file and if you do something like this.
..the result will be an unstable fileCode:Private Sub Command1_Click()
Dim sold As String, snew As String
sold = "C:\my documents\MyWord.doc"
snew = "C:\my documents\myword.xls"
Name sold As snew
End Sub
Thank you HeSaidJoe. For this one, I realise this well raised point, but this program is for being devious.
I (like 99% of people methinks) get lots of jokes & pics in their e-mails which I forward. One of my mates companies have upgraded their firewalls though & this won't allow any files other than with MSOffice extensions through.
Solution - a great little program by Alex. I rename the file to .doc my end, send it through with note of what the extension should be. ;)