|
-
Nov 17th, 2000, 11:43 AM
#1
Thread Starter
Evil Genius
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
-
Nov 17th, 2000, 11:48 AM
#2
Addicted Member
Try the Name command.
Code:
Name oldpathname As newpathname
Hope this helps.
Michael
Application/Web Developer
Visual Basic 6.0 SP5
Active Server Pages
Oracle 9i
- I'm going to live forever, or die trying!
-
Nov 17th, 2000, 11:49 AM
#3
Frenzied Member
Try
Code:
shell "Rename " & yourOldFile & " " & Left(yourOldFile,len(youOldFile)-4) & ".xls"
you can change Left(yourOldFile,len(youOldFile)-4) by
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
-
Nov 17th, 2000, 11:52 AM
#4
Thread Starter
Evil Genius
ahhhhhh, thank you for that one, I was looking at change name, alter, ren, rename, everything but
-
Nov 17th, 2000, 11:55 AM
#5
Frenzied Member
Yeah I agree with Michael, use NAME, but be sure to include the whole directory with it:
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"
Have fun!
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Nov 17th, 2000, 04:34 PM
#6
_______
<?>
Remeber, by changing the extension of a file you are not changing the type of the file and if you do something like this.
Code:
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
..the result will be an unstable file
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 20th, 2000, 03:31 AM
#7
Thread Starter
Evil Genius
awkward one
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|