Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default workbooks.open - another option

I will be accessing several workbooks (test.xls, test1.xls, ...).

What is the syntax to "reference" workbook without having to open it?

thanks
-Mona

Set wbkTarget = Workbooks.open(Filename:="c:\ test.xls")
If wbkTarget Is Nothing Then
MsgBox "Can not open file"
Else
Set wksTarget = wbkTarget.Sheets("Summary")
If wksTarget Is Nothing Then
MsgBox "Could not locate sheet"
Else
lRow_2006 = Sheets("Summary").Range("A" & _
Sheets("Summary").Rows.count).End(xlUp).Row
End If
End If
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default workbooks.open - another option

You mean to retrieve values from cells on a worksheet?

You can use helper cells in a worksheet and build formulas to do the work

or

You could retrieve values from a closed workbook using a routine from John
Walkenbach:
http://j-walk.com/ss/excel/eee/eee009.txt
Look for either: GetDataFromClosedFile or GetValue.

Mona wrote:

I will be accessing several workbooks (test.xls, test1.xls, ...).

What is the syntax to "reference" workbook without having to open it?

thanks
-Mona

Set wbkTarget = Workbooks.open(Filename:="c:\ test.xls")
If wbkTarget Is Nothing Then
MsgBox "Can not open file"
Else
Set wksTarget = wbkTarget.Sheets("Summary")
If wksTarget Is Nothing Then
MsgBox "Could not locate sheet"
Else
lRow_2006 = Sheets("Summary").Range("A" & _
Sheets("Summary").Rows.count).End(xlUp).Row
End If
End If


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default !

I wanted to retrieve data from close file.

Thank you!

"Dave Peterson" wrote:

You mean to retrieve values from cells on a worksheet?

You can use helper cells in a worksheet and build formulas to do the work

or

You could retrieve values from a closed workbook using a routine from John
Walkenbach:
http://j-walk.com/ss/excel/eee/eee009.txt
Look for either: GetDataFromClosedFile or GetValue.

Mona wrote:

I will be accessing several workbooks (test.xls, test1.xls, ...).

What is the syntax to "reference" workbook without having to open it?

thanks
-Mona

Set wbkTarget = Workbooks.open(Filename:="c:\ test.xls")
If wbkTarget Is Nothing Then
MsgBox "Can not open file"
Else
Set wksTarget = wbkTarget.Sheets("Summary")
If wksTarget Is Nothing Then
MsgBox "Could not locate sheet"
Else
lRow_2006 = Sheets("Summary").Range("A" & _
Sheets("Summary").Rows.count).End(xlUp).Row
End If
End If


--

Dave Peterson

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
Is there a template option for Workbooks.Add(xlWBATWorksheet)? Hank Scorpio Excel Discussion (Misc queries) 6 August 11th 09 09:37 AM
workbooks.open function fails to open an existing excel file when used in ASP, but works in VB. san Excel Programming 1 January 3rd 06 03:22 AM
I want to merge two workbooks but the option is greyed out. Why? MOC Excel Discussion (Misc queries) 1 October 12th 05 01:52 AM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM
Workbooks.Open / .Open Text - How do you stop the .xls addition? Dave[_20_] Excel Programming 2 July 31st 03 04:03 AM


All times are GMT +1. The time now is 02:46 AM.

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"