Results 1 to 5 of 5

Get value from closed workbook Excel 2010

Threaded View

  1. #1
    Registered User
    Join Date
    04-27-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    18

    Question Get value from closed workbook Excel 2010

    Hello,

    I was using this code to get value from closed workbook in excel 2003. Now my company upgraded to office 2010 and it is not working any more. Is there a way to adjust the code to suit new software or replace with some other commands? I also tried MoreFunctions add-on to use better INDIRECT formula, but it seems it doesn't work with 2010 excel as well. Thanks you for you help in advance. Here is my code:

    Sub CommandButton1_Click()
        p = "D:\User\"
        f = "ABC.xlsx"
        s = "Sheet1"
        a = "A1"
        Range("A2") = GetValue(p, f, s, a)
    End Sub
    
    Private Function GetValue(path, file, sheet, ref)
    '   Retrieves a value from a closed workbook
        Dim arg As String
    '   Make sure the file exists
        If Right(path, 1) <> "\" Then path = path & "\"
        If Dir(path & file) = "" Then
            GetValue = "File Not Found"
            Exit Function
        End If
    '   Create the argument
        arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
          Range(ref).Range("A1").Address(, , xlR1C1)
    '   Execute an XLM macro
        GetValue = ExecuteExcel4Macro(arg)
    End Function
    Any suggestions with this issue? Is it possible or maybe not?
    Last edited by Karolis; 12-15-2011 at 05:29 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1