Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Excel Macro - Relative Path

Hi Skip,

You could use something like the following 'GetFolder' function to browse
for a 'base' folder:

Function GetFolder(Optional Title As String = "Select a Folder", Optional
RootFolder As Variant) As String
On Error Resume Next
GetFolder = CreateObject("Shell.Application").BrowseForFolder( 0, Title, 0,
RootFolder).Items.Item.Path
End Function

This macro shows how the 'GetFolder' function might be implemented:

Sub Test()
Fold = GetFolder(Title:="Find a Folder", RootFolder:=&H11)
MsgBox Fold
End Sub

Cheers


"Skip" wrote in message
...
Hello all,

I am not a programmer but I do record Macros using the Macro Recorder in
Excel and can edit the results. Really grateful for any help with this.

I have a spreadsheet say c:\01\01.xls. Beneath this directory is a tree of
directors containing Excel sheets that are opened, manipulated, closed and
saved via a Macro in c:\01\01.xls.

Works fine, but I want to replicate the structure by copying the entire
structure across to c:\02, c:\03, c:\04, etc.Problem is, the Macros

contain
an absolute path and so still refer to the spreadsheets in the c:\01 tree.
Is there any way to edit the path to relative and therefore make the tree
structure portable? If it's a complex solution, please give me as much
detail as you can and give an example of how and where the code should be
inserted.

Many thanks.




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.725 / Virus Database: 480 - Release Date: 19/07/2004


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Excel Macro - Relative Path

Hello all,

I am not a programmer but I do record Macros using the Macro Recorder in
Excel and can edit the results. Really grateful for any help with this.

I have a spreadsheet say c:\01\01.xls. Beneath this directory is a tree of
directors containing Excel sheets that are opened, manipulated, closed and
saved via a Macro in c:\01\01.xls.

Works fine, but I want to replicate the structure by copying the entire
structure across to c:\02, c:\03, c:\04, etc.Problem is, the Macros contain
an absolute path and so still refer to the spreadsheets in the c:\01 tree.
Is there any way to edit the path to relative and therefore make the tree
structure portable? If it's a complex solution, please give me as much
detail as you can and give an example of how and where the code should be
inserted.

Many thanks.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Excel Macro - Relative Path

Many thanks Macropod.

So if I have a recorded Macro containing the following:

ChDir "C:\MI\01"
Workbooks.Open FileName:=
_"C:\MI\01\01.csv
Workbooks.Open FileName:=
_"C:\MI\01\02.csv

etc, etc...

How would I edit the code to find MI as the root directory with the relative
path from there down to various sub directories?

Apologies if this is basic, but I'm unsure how to implement.

Thanks.


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
Relative Path to a Folder Heliocracy Excel Discussion (Misc queries) 3 October 3rd 07 04:28 PM
how to change absolute path to relative path hwijgerse Excel Worksheet Functions 0 November 25th 05 07:18 AM
Absolute vs Relative path K2H Excel Discussion (Misc queries) 2 July 28th 05 12:50 PM
Relative path Giovaz Excel Programming 3 July 13th 04 02:21 PM
relative path. Bob Kilmer Excel Programming 0 September 12th 03 12:25 AM


All times are GMT +1. The time now is 04:41 PM.

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

About Us

"It's about Microsoft Excel"