View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Getafile from Cellref Path

Ok Tom, that did the trick....using your testing hints, I eventually found
that my test-shortcut of using ThisWorkBook.Path did not work so well, and
when I finally put a real path in H30, all went well.

Thanks for straightening me out.........

Vaya con Dios,
Chuck, CABGx3




"Tom Ogilvy" wrote:

no reason it wouldn't work if it produces the same string. Test it and see

Dim s as String
s = Range("MainMenu!h30").Value & "\MyFileName.XLS"
msgbox s '<== optional, but useful until you have it working
if dir(s) < "" then
Workbooks.Open FileName:= s
else
msgbox s & " Not found"
End if

Assumes this code is not in a sheet module rather than a general module and
it isn't within the scope of an on error resume next statement. If so, you
might try

s = Application.Range("MainMenu!h30").Value & "\MyFileName.XLS"

--
Regards,
Tom Ogilvy

"CLR" wrote:

Hi All..........

I'm trying to open a workbook from a Path that is subject to change, and is
therefore entered by the user in cell MainMenu!H30. I've tried this, with
the Path in the referenced cell, but no joy.

Workbooks.Open FileName:=Range("MainMenu!h30").Value & "\MyFileName.XLS"

I get a pop-up saying that the correct path and filename "could not be found".
but if I hardcode the same path and filename it works fine


Any help would be much appreciated.

Vaya con Dios,
Chuck, CABGx3