Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JM JM is offline
external usenet poster
 
Posts: 37
Default Get Values from Closed Excel

I have two excel spreadsheets: test.xls and test2.xls

test.xls has information i want to automatically pull into test2.xls, and I
would like keep test.xls closed during this process. test2.xls will be open
when the command is given.

test.xls has the following characteristics
path: K:\Data Directories\
name: test.xls
sheet: mastedb Query
cells needed: A1:DV126

test2.xls has the follwing characteristics
path: K:\Data Directories\
name: test2.xls
sheet: test
can put data starting at cell: A1

It would be great, because I am an intern and under the gun to figure this
out, if someone could help me write the whole VBA command using the
information that I've placed above. I just can't see where to put
everything, and I keep getting errors. Thank you in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Get Values from Closed Excel

Why not open it ?

Maybe you can use ADO
http://www.rondebruin.nl/ado.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl


"jm" wrote in message ...
I have two excel spreadsheets: test.xls and test2.xls

test.xls has information i want to automatically pull into test2.xls, and I
would like keep test.xls closed during this process. test2.xls will be open
when the command is given.

test.xls has the following characteristics
path: K:\Data Directories\
name: test.xls
sheet: mastedb Query
cells needed: A1:DV126

test2.xls has the follwing characteristics
path: K:\Data Directories\
name: test2.xls
sheet: test
can put data starting at cell: A1

It would be great, because I am an intern and under the gun to figure this
out, if someone could help me write the whole VBA command using the
information that I've placed above. I just can't see where to put
everything, and I keep getting errors. Thank you in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
JM JM is offline
external usenet poster
 
Posts: 37
Default Get Values from Closed Excel

can you help me write this code? the test.xls will remain closed during this
process -- that's what my boss wants, so i have to figure out how to do this
with test.xls closed.

so, i need to ask again. can you show me how to write this VBA with the
characteristics that i outline below?

test.xls has information i want to automatically pull into test2.xls, and I
would like keep test.xls closed during this process. test2.xls will be open
when the command is given.

test.xls has the following characteristics
path: K:\Data Directories\
name: test.xls
sheet: mastedb Query
cells needed: A1:DV126

test2.xls has the follwing characteristics
path: K:\Data Directories\
name: test2.xls
sheet: test
can put data starting at cell: A1
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Get Values from Closed Excel

You can download the Example zip on the site
The first macro show you how to get information out of the closed file

You can use this code in your test2.xls to get the information

--
Regards Ron de Bruin
http://www.rondebruin.nl


"jm" wrote in message ...
can you help me write this code? the test.xls will remain closed during this
process -- that's what my boss wants, so i have to figure out how to do this
with test.xls closed.

so, i need to ask again. can you show me how to write this VBA with the
characteristics that i outline below?

test.xls has information i want to automatically pull into test2.xls, and I
would like keep test.xls closed during this process. test2.xls will be open
when the command is given.

test.xls has the following characteristics
path: K:\Data Directories\
name: test.xls
sheet: mastedb Query
cells needed: A1:DV126

test2.xls has the follwing characteristics
path: K:\Data Directories\
name: test2.xls
sheet: test
can put data starting at cell: A1



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Get Values from Closed Excel

Try this code:

Function GetValueFromWB(path, file, sheet, ref)

'Retrieves a value from a closed workbook
'----------------------------------------
Dim strSep As String
Dim arg As String

strSep = "\"

'Make sure the file exists
'-------------------------
If Right$(path, 1) < strSep Then path = path & strSep
If bFileExists(path & file) = False Then
GetValueFromWB = "File Not Found"
Exit Function
End If

'Create the argument
'-------------------
arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
Range(ref).Range("A1").Address(, , xlR1C1)

'Execute an XLM macro
'--------------------
GetValueFromWB = ExecuteExcel4Macro(arg)

End Function

Function bFileExists(strFile As String) As Boolean
bFileExists = (Len(Dir(strFile)) 0)
End Function


RBS


"jm" wrote in message
...
I have two excel spreadsheets: test.xls and test2.xls

test.xls has information i want to automatically pull into test2.xls, and
I
would like keep test.xls closed during this process. test2.xls will be
open
when the command is given.

test.xls has the following characteristics
path: K:\Data Directories\
name: test.xls
sheet: mastedb Query
cells needed: A1:DV126

test2.xls has the follwing characteristics
path: K:\Data Directories\
name: test2.xls
sheet: test
can put data starting at cell: A1

It would be great, because I am an intern and under the gun to figure this
out, if someone could help me write the whole VBA command using the
information that I've placed above. I just can't see where to put
everything, and I keep getting errors. Thank you in advance.




  #6   Report Post  
Posted to microsoft.public.excel.programming
JM JM is offline
external usenet poster
 
Posts: 37
Default Get Values from Closed Excel

I've seen that code before (or something that looks very similiar)...for the
last three days, I've gone through almost every thread that says "closed
excel" (or the like) -- and my problem is that i have no idea what this stuff
means b/c there is never any good live examples...

it would probably take you or someone else minutes to show me an example
using the information that i have given (see start of thread). it's
frustrating not being able to get something to work, and i'm posting this b/c
i've already been to all the links and have read all the chat rooms...and i'm
at a lost to get it working.

can you help me out with my specific example? it would be greatly
appreciated.
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Get Values from Closed Excel

OK, if I take you exact example (apart from the path):

Sub testing()

Dim arr

arr = GetValueFromWB("C:\", _
"test.xls", _
"mastedb Query", _
Range(Cells(1), Cells(126, 126)).Address)

Range(Cells(1), Cells(126, 126)) = arr

End Sub

I have tested this and it work fine.

RBS



"jm" wrote in message
...
I've seen that code before (or something that looks very similiar)...for
the
last three days, I've gone through almost every thread that says "closed
excel" (or the like) -- and my problem is that i have no idea what this
stuff
means b/c there is never any good live examples...

it would probably take you or someone else minutes to show me an example
using the information that i have given (see start of thread). it's
frustrating not being able to get something to work, and i'm posting this
b/c
i've already been to all the links and have read all the chat rooms...and
i'm
at a lost to get it working.

can you help me out with my specific example? it would be greatly
appreciated.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Get Values from Closed Excel

To deal with your sheet test as well in the open workbook:

Sub testing()

Dim arr

arr = GetValueFromWB("C:\", _
"test.xls", _
"mastedb Query", _
Range(Cells(1), Cells(126, 126)).Address)

With Sheets("test")
Range(.Cells(1), .Cells(126, 126)) = arr
End With

End Sub


RBS


"jm" wrote in message
...
I've seen that code before (or something that looks very similiar)...for
the
last three days, I've gone through almost every thread that says "closed
excel" (or the like) -- and my problem is that i have no idea what this
stuff
means b/c there is never any good live examples...

it would probably take you or someone else minutes to show me an example
using the information that i have given (see start of thread). it's
frustrating not being able to get something to work, and i'm posting this
b/c
i've already been to all the links and have read all the chat rooms...and
i'm
at a lost to get it working.

can you help me out with my specific example? it would be greatly
appreciated.


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
coppied Graph changes values when original is closed Keith H[_2_] Charts and Charting in Excel 0 February 9th 09 12:37 PM
Reading values from a closed workbook Graham F New Users to Excel 6 July 28th 08 03:32 PM
How can I add values to a closed excel file? Ali Excel Worksheet Functions 8 June 11th 05 01:13 AM
Pasting values from a closed Excel instance Jan Kronsell[_3_] Excel Programming 3 April 27th 05 07:12 AM
Getting values from a closed file Shelley[_2_] Excel Programming 2 November 21st 03 07:50 PM


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

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

About Us

"It's about Microsoft Excel"