Consulting

Results 1 to 4 of 4

Thread: Reading values from a closed excel sheet

  1. #1

    Question Reading values from a closed excel sheet

    Hi guys,

    Can you please help me out with some sample code, how to access a closed excel file from a particular folder using vba code.

    My consern is everytime i need to open a differet closed excel.


  2. #2
    please some one help me..
    it's urgent

  3. #3
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    You should allow time for an answer. If you bump your post, it may not be seen as a 0 response will get more attention. You can bump if more than 1 day has passed.

    To get one value:
    [vba]Sub t()
    MsgBox GetInfoFromClosedFile(ThisWorkbook.path, ThisWorkbook.Name, "Sheetx", "A1")
    MsgBox Workbooks(ThisWorkbook.path & "\PageSetup2.xls").Name
    End Sub

    Private Function GetInfoFromClosedFile(ByVal wbPath As String, _
    wbName As String, wsName As String, cellRef As String) As Variant
    Dim arg As String
    GetInfoFromClosedFile = ""
    If Right(wbPath, 1) <> "\" Then wbPath = wbPath & "\"
    If Dir(wbPath & "\" & wbName) = "" Then Exit Function
    arg = "'" & wbPath & "[" & wbName & "]" & _
    wsName & "'!" & Range(cellRef).Address(True, True, xlR1C1)
    On Error Resume Next
    GetInfoFromClosedFile = ExecuteExcel4Macro(arg)
    End Function[/vba]

  4. #4
    Ok Thanks a lot..

Posting Permissions

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