Open a workbook from a written path

  • Thread starter Thread starter Ricardo Silva
  • Start date Start date
R

Ricardo Silva

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
 
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
 
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.
 
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
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top