LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Trouble renaming Folders

Last week I posted a question about moving and renaming of folders and files
(Moving A Folder 10/24/04). This procedure works great if the StrFromPath
variable is in the following format ("C:\testme1"). It does not seem to
work if I use a variable in the path ("C:\" & StrName). The code below shows
the method in which I am trying to accomplish this. I am using a
label.caption as the variable. Every time I go to set the objFolder I get a
"Path not found", which cause an "Object not set" when defining the new
name... Very frustrating.
I am referencing both the Runtime Library and the Script Object 1.0.

Any ideas? Please?

Sub RenameFolder()
Dim StrPath As String
Dim StrName As String
Dim NewName As String
Dim Fso As New FileSystemObject
Dim objFolder As Scripting.Folder
Dim objFile As Scripting.File

On Error Resume Next

Set Fso = New Scripting.FileSystemObject

StrName = F_Admin.LabelEO.Caption

StrPath = " C:\Documents and Settings\" & fOSUserName & "\My Documents\excel
****\New_EO\Pending EOs\" & StrName
Set objFolder = Fso.GetFolder(StrPath)

NewName = Right(StrName, Len(StrName) - 1)

objFolder.Name = NewName
objFile.Name = NewName

Set objFso = Nothing
Set objFolder = Nothing
Set objFile = Nothing

End Sub



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
TROUBLE RENAMING A WORKSHEET IN EXCEL 2000 Cat Excel Worksheet Functions 2 June 17th 06 05:38 PM
renaming No Name Excel Programming 1 October 11th 04 05:01 PM
Renaming folders Robin Clay[_3_] Excel Programming 6 August 12th 04 05:12 PM
Renaming ianripping[_66_] Excel Programming 3 May 22nd 04 12:02 PM
Renaming within VBA Brent McIntyre Excel Programming 4 August 21st 03 02:10 AM


All times are GMT +1. The time now is 03:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"