Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Write Procedure With Logic Test To Open File From Given Directory

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Write Procedure With Logic Test To Open File From Given Directory

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Write Procedure With Logic Test To Open File From Given Directory

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Write Procedure With Logic Test To Open File From Given Directory

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Write Procedure With Logic Test To Open File From Given Direct

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
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
open file in current directory Tomo Excel Discussion (Misc queries) 1 January 11th 08 11:48 PM
Getting open file's directory, captureing user login ID, write access Claud Balls Excel Programming 2 December 23rd 04 11:47 PM
Open file in directory Mike Excel Programming 2 February 20th 04 08:02 PM
How to retrieve the directory of the currently open file? Joepy Excel Programming 2 August 7th 03 03:02 PM


All times are GMT +1. The time now is 08:50 AM.

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"