Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Moving a folder

Yep, that's the ticket. Thanks a million Jim. And thanks to all the MVP's
for their help. Time for this app to go to BETA. You Guys/Girls are the
best.

"Jim Cone" wrote:

John,

I just tried the following code and it worked for me...
(Note also that you can rename a file or folder using the Name statement in VBA)

'-----------------------------------------------
' Requires reference to "Microsoft Scripting Runtime" in the VBA project.
' Following code moves the Analysis folder from the Library folder to the C drive
' and renames the folder and its files.
' Jim Cone - October 24, 2004

Sub MoveFolderWithScriptingRuntime()
Dim strFromPath As String
Dim strToPath As String
Dim strName As String
Dim Fso As Scripting.FileSystemObject
Dim objFolder As Scripting.Folder
Dim objFile As Scripting.File

Set Fso = New Scripting.FileSystemObject

'Specify path of folder to be moved.
strFromPath = "C:\Program Files\Microsoft Office\Office\Library\Analysis"
'Retain folder name in variable.
Set objFolder = Fso.GetFolder(strFromPath)
strName = objFolder.Name

'Specify new location for folder.
strToPath = "C:\"
'Move the folder.
Fso.MoveFolder strFromPath, strToPath

'Establish a reference to the folder in the new location.
Set objFolder = Fso.GetFolder(strToPath & "\" & strName)

'Skip this part if you only want to rename the folder
'Rename each file in the folder.
For Each objFile In objFolder.Files
objFile.Name = "X" & objFile.Name
Next 'objFile

'Rename the folder.
objFolder.Name = "X" & objFolder.Name

'Technically not required, but I prefer it.
Set objFolder = Nothing
Set objFile = Nothing
Set Fso = Nothing
End Sub
'-----------------------------------------------

Regards,
Jim Cone
San Francisco, CA

"asmenut" wrote in message ...
Thanks Jim. Works great. But, is there a way to rename the folder / file to
reflect a new location (i.e. E28802 - 28802). A little explanation might
help:

Once the file is authorized, the Log number is changed (so as to reflect the
approval of the Engineering Order) (Log Number E28802 - 28802). This folder
(once approved) will contain all the pertinent files required to process the
Order. When the file and folder is renamed and moved, the EO admin will be
able to set tracking options throughout the rest of the process (i.e.
routing, processing, archiving, etc)

John,


-snip-

Reply
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
Moving excel workbook with access query to another folder Nick Excel Discussion (Misc queries) 0 January 6th 10 03:00 PM
Moving a folder containing linked excel files? CNN Excel Discussion (Misc queries) 0 November 4th 08 03:29 PM
Macro help - Moving 2 cells from 100 separate files into new folder Steven Excel Discussion (Misc queries) 7 July 10th 07 07:47 PM
How to decide folder-depth or How to select more folders/subfolders (folder-tree) ? Subteam Excel Discussion (Misc queries) 2 May 7th 06 08:14 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM


All times are GMT +1. The time now is 11:09 PM.

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"