Retrieving data if file being accessed elsewhere

  • Thread starter Thread starter Karen
  • Start date Start date
K

Karen

Hi All
I have a macro that will access a file across the network retrieving
data. If I try to access a file that is already opened elsewhere I
presume there will be an error message along the lines of "This file
is being accessed by....."
In VB would Application.DisplayAlerts = False enable opening up the
file "Read-Only" if necessary so as to import the data?

Karen
 
I think you'll just want to open the file in readonly mode:

Look at workbooks.open in VBA's help. You'll see a parm that allows you to
specify to open up in readonly mode:

Option Explicit
Sub testme()
Dim newWkbk As Workbook
Set newWkbk = Workbooks.Open(Filename:="\\myserver\myfolder\test.xls", _
ReadOnly:=True)
End Sub
 
Back
Top