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: 15
Default modify macro to execute based on current path

I've been using the macro below, which works a great. However, I would like
to modify the macro such that the directory path does not have to be
specified. That is, instead, the macro would identify the path of the
orginally opened workbook (from which the macro is executed) and then look
within that path for the folder named 'Groups', and then execture the called
macro on all of the workbooks within the Groups folder.

I thought it would be as simple as adding:

Dim MyPath As String
MyPath = Application.ThisWorkbook.path

and

Const path = MyPath & ("Groups") & "\"

....but that didn't work (i.e., debugger says the path can not be found. Any
advice greatly appreciated.


Sub ProcessAllFiles()

Dim sFile$

Const path = "C:\Groups\"

sFile = Dir(path & "*.xls")
Do While sFile < ""
'the new workbook will become active
Workbooks.Open (path & sFile)
'run your macro here
Call gema_fit_calculations_groups
'however make sure that the new workbook
'remains active throughout the macro
'Macro1
ActiveWorkbook.Close savechanges:=True
sFile = Dir
Loop

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
How to execute macro based on a users computer settings Daddy Mac will make ya JUMP JUMP Excel Programming 3 May 9th 08 04:31 PM
Execute Macros from Other workbooks on current workbook Allen[_13_] Excel Programming 1 July 6th 06 02:08 AM
How do I execute a macro based on the value of a cell in Excel? brettopp Excel Discussion (Misc queries) 12 June 17th 06 01:27 AM
How can I get a macro to execute in excel based on the value of a. Ian P[_2_] Excel Programming 2 April 19th 05 09:50 PM
Current path to Qualified Path Mary Excel Programming 1 October 14th 04 02:42 PM


All times are GMT +1. The time now is 10:11 AM.

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"