Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 2nd, 2008, 01:10 AM
Registered User
Join Date: Dec 2007
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,

Old March 24th, 2008, 06:20 PM
Authorized User
Join Date: Mar 2008
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

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

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.