Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old February 2nd, 2008, 12:10 AM
Registered User
Join Date: Dec 2007
Location: , , Australia.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Renaming long file name with VBA

Can anyone please advise on limitations to file name lengths in VBA?

I am trying to Rename a file on a server with a long address.

Name strA as strB <<< where strA and strB are .zip file names of 172 characters, does not work.

Similarly using FileSystemObject does not work:

dim fso as object
Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile strA, strB
Set fso = Nothing

I would be grateful for any suggestions on how to get around this problem

many thanks,

Reply With Quote
  #2 (permalink)  
Old March 24th, 2008, 06:20 PM
Authorized User
Join Date: Mar 2008
Location: Athens, , Greece.
Posts: 35
Thanks: 0
Thanked 1 Time in 1 Post

Hi Jil,
it's been ages since your opening post and chances are you have found the answer to your problem. Would be nice if you shared it with us.

Still, in case there has been no solution, I'd like to say that I tried it with a 180-char file name and it all worked out smoothly.
Sub RenameFile()
Dim file1 As String, file2 As String, path1 As String
file1 = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.zip"
file2 = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567899.zip"
path1 = "C:\FolderA\FolderB"
Name path1 & "\" & file1 As path1 & "\" & file2
End Sub
My guess is that it had something to do with the path and not the filename. But still, you never mentioned what kind of message you got, so...

Regards, tstav

Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming fields in access table using VBA imaley Access VBA 13 August 13th, 2009 02:22 PM
Long SQL Query (>1024) in VBA??? mlep Excel VBA 1 June 14th, 2007 08:41 PM
Renaming File ayazhoda Access VBA 3 April 24th, 2007 05:43 AM
Renaming a file during upload keph Pro PHP 1 October 6th, 2005 07:14 PM
Renaming File During Upload keph Beginning PHP 1 October 4th, 2005 02:46 PM

All times are GMT -4. The time now is 02:43 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.