Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
TROUBLE RENAMING A WORKSHEET IN EXCEL 2000 | Excel Worksheet Functions | |||
renaming | Excel Programming | |||
Renaming folders | Excel Programming | |||
Renaming | Excel Programming | |||
Renaming within VBA | Excel Programming |