Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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.
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
open Workbook path Boba Excel Programming 6 May 7th 08 11:04 PM
Can a macro be written that when you open a workbook the zoom will be set for each sheet? Marc Excel Programming 5 April 6th 06 02:14 AM
Open Workbook using URL instead of network path Raul Excel Programming 5 March 1st 06 03:53 PM
Get path of open workbook Peridox Excel Programming 1 November 29th 05 05:46 AM
how to open workbook without hardcoding path Michael Turner Excel Programming 3 November 20th 03 12:12 PM


All times are GMT +1. The time now is 11:54 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"