Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ref the line: MyPath = "C:\" in the sub below (from Mike H)
how can I make the path (the "C:\" bit) as a variable for the sub/Excel to pick up? The path will be different everyday. I'd navigate to the desired folder upon running the sub (via a "FileOpen"), then the sub will do the rest of the processes on the files in that folder. Thanks. Sub LoopThroughDirectory() Application.DisplayAlerts = False 'Change this to your directory MyPath = "C:\" Dim wbNew As Workbook Set wbNew = Workbooks.Add() wbNew.SaveAs Filename:=MyPath & "1234.xls" For x = 1 To 4 Workbooks.Open Filename:=MyPath & x & ".xls" 'Here is the line that calls the macro below, passing the workbook to it DoSomething ActiveWorkbook ActiveWorkbook.Close savechanges:=False Next Application.DisplayAlerts = True End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Open Dialog Box to return Selected File Path and Not Open it. | Excel Programming | |||
specify default path in dialog open box | Excel Programming | |||
dialog box to pick path & file | Excel Programming | |||
open dialog box for file path | Excel Programming | |||
Getting the full path when from a File Open Dialog Box | Excel Programming |