Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Getafile from Cellref Path

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Getafile from Cellref Path

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


  #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


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
Formula too long - new file path is shorter than old file path - Excel 2003 Greg J Excel Worksheet Functions 1 November 22nd 06 05:16 PM
Finding CellRef for Control+Home Jim May Excel Programming 12 May 31st 06 07:04 PM
hyperlink navigation path path wrong in Excel 2003 CE Admin Excel Discussion (Misc queries) 5 January 7th 06 07:47 PM
how to change absolute path to relative path hwijgerse Excel Worksheet Functions 0 November 25th 05 07:18 AM
Current path to Qualified Path Mary Excel Programming 1 October 14th 04 02:42 PM


All times are GMT +1. The time now is 12:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"