why won't this work?

P

PBcorn

The below gives error 9: subscript out of range (when error handling is not
used). I thought it might be to do with workbooks(path), but not sure. It is
located in the ThisWorkbook object.



Private Sub workbook_open()

'sub to force intermediate xlwb to update its links without opening it

'Dim msg As String

On Error GoTo ms

with Workbooks("G:\filepath\filepath\file.xls")

..UpdateLink Name:=.LinkSources

end with

Exit Sub

ms:
msg = "links may have not updated properly" & vbNewLine
msg = msg & "open relevant file"
MsgBox msg


End Sub
 
A

Alan Moseley

From the help file, the Workbooks property:-

Returns a Workbooks collection that represents all the open workbooks.

Try changing your line to:-

With Workbooks.Open("G:\filepath\filepath\file.xls")
 
P

PBcorn

excellent - that works. If you have time - is there a way of stopping the
update links dialog box from appearing when the file is opened?

Thanks
 
A

Alan Moseley

In the source workbook go to Edit, Links. Click on the Startup Prompt button
and change the setting to 'Dont display the alert and update the links'.
 

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

Top