Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to write a procedure (not sure if this is what you call it) to cause
the file "data.xls" to be opened from path "C:\data\FEB" if the month is February (evidenced by the text "FEB" in cell L45 in worksheet "Process") and a file with the same name to be opened from path "C:\data\MAR" if the month is March (evidenced by the text "MAR" in cell L45 of worksheet "Process"). This may be simple for some but I don't even know where to start. Thanks! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Carl,
the file "data.xls" to be opened from path "C:\data\FEB" if the month is February (evidenced by the text "FEB" in cell L45 in worksheet "Process") and Try: workbooks.Open FileName:="C:\data\" & Sheets ("Process").Range("L45").Value & "\data.xls" Best Markus |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks a million Markus! This worked great and has opened up a whole new
world to me! "Markus Scheible" wrote: Hi Carl, the file "data.xls" to be opened from path "C:\data\FEB" if the month is February (evidenced by the text "FEB" in cell L45 in worksheet "Process") and Try: workbooks.Open FileName:="C:\data\" & Sheets ("Process").Range("L45").Value & "\data.xls" Best Markus |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
OK,
if I've undestood, you want to open files with the same names and different paths variable on a cell value. If this is correct, do as follows: Create a command button (from the Control Toolbox) and (in the Design Mode - always selectable in the Control Tollbox Taskbar) double click it. A macro screen will popup with a couple of lines written: Private Sub CommandButton1_Click() ' Here write the following code End Sub The following code will create from cell L45 the right path and will open the file (without ""): ' Starts Here dim sPath as string dim sPartialPath as string dim sFileName as string sFileName = "data.xls" sPartialPath = worksheets("Process").cells(45,12).value sPath = "C:\data\" & sPartialPath & "\" & sFileName Workbooks.open(sPath) ' Finishes Here Now, saving and then pushing the button (NOT in Design Mode) the desired file should be opened. Hope it Helps, David |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, David. I will need to study this more. I was able to use the other
suggestion and it worked just fine. I still see some use for what you are saying. "David Fam?" wrote: OK, if I've undestood, you want to open files with the same names and different paths variable on a cell value. If this is correct, do as follows: Create a command button (from the Control Toolbox) and (in the Design Mode - always selectable in the Control Tollbox Taskbar) double click it. A macro screen will popup with a couple of lines written: Private Sub CommandButton1_Click() ' Here write the following code End Sub The following code will create from cell L45 the right path and will open the file (without ""): ' Starts Here dim sPath as string dim sPartialPath as string dim sFileName as string sFileName = "data.xls" sPartialPath = worksheets("Process").cells(45,12).value sPath = "C:\data\" & sPartialPath & "\" & sFileName Workbooks.open(sPath) ' Finishes Here Now, saving and then pushing the button (NOT in Design Mode) the desired file should be opened. Hope it Helps, David |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
open file in current directory | Excel Discussion (Misc queries) | |||
Getting open file's directory, captureing user login ID, write access | Excel Programming | |||
Open file in directory | Excel Programming | |||
How to retrieve the directory of the currently open file? | Excel Programming |