Read And Write On A Closed Wbook

  • Thread starter Thread starter sal21
  • Start date Start date
S

sal21

i have a closed wbook on a server dir is possible to read and write o
this without open it
 
This function will do it. Can't remember where I got it from.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top