View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Carl Bowman Carl Bowman is offline
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