ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open a workbook from a written path (https://www.excelbanter.com/excel-programming/417402-open-workbook-written-path.html)

Ricardo Silva[_2_]

Open a workbook from a written path
 
Hi,
I would like to run a macro that would open a workbook in which the path is
written in a cell.
Can someone help me?
Cheers
Ricardo

Gary Keramidas

Open a workbook from a written path
 
one way, but you don't specify if the path has a trailing backslash or not,
whether you want read only or not.
there are a few options.


i just used B3 on sheet1 and my value didn't have a backslash, so i added one
within the code


Sub open_file()
Dim ws As Worksheet
Dim fpath As String

Set ws = Worksheets("Sheet1")
fpath = ws.Range("B3").Value & "\"
Workbooks.Open (fpath & "filename.xls")

End Sub

--


Gary


"Ricardo Silva" wrote in message
...
Hi,
I would like to run a macro that would open a workbook in which the path is
written in a cell.
Can someone help me?
Cheers
Ricardo




Boris[_3_]

Open a workbook from a written path
 
On Sun, 21 Sep 2008 21:23:02 -0700, Ricardo Silva wrote:

Hi,
I would like to run a macro that would open a workbook in which the path is
written in a cell.
Can someone help me?
Cheers
Ricardo


If path is stored in cell B2 on Sheet1, the macro would contain this:

Workbooks.Open ThisWorkbook.Worksheets("Sheet1").Range("B2").Text

HTH

B.

HappySenior[_2_]

Open a workbook from a written path
 
On Sep 21, 10:41*pm, Boris wrote:
On Sun, 21 Sep 2008 21:23:02 -0700, Ricardo Silva wrote:
Hi,
I would like to run a macro that would open a workbook in which the path is
written in a cell.
Can someone help me?
Cheers
Ricardo


If path is stored in cell B2 on Sheet1, the macro would contain this:

Workbooks.Open ThisWorkbook.Worksheets("Sheet1").Range("B2").Text

HTH

B.


Gary and Boris,
I get a subs-script out of range on both proposed solutions. I used
"A20" as my range. Ideas?
Don in Montana

dan dungan

Open a workbook from a written path
 
Hi Don,

It worked for me for Excel 2000 using

Sub openfile()
Workbooks.Open ThisWorkbook.Worksheets("Sheet1").Range("a3").Text
End Sub

Did you change the range to match "A20"?

If so, it sounds like your path is not complete, to me.

Dan


Boris[_3_]

Open a workbook from a written path
 
On Mon, 22 Sep 2008 15:09:15 -0700 (PDT), HappySenior wrote:

Gary and Boris,
I get a subs-script out of range on both proposed solutions. I used
"A20" as my range. Ideas?
Don in Montana


Have you changed "Sheet1" to the name of your worksheet and entered "A20"
as a range?

B.


All times are GMT +1. The time now is 05:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com