Capture Update Links Error?

S

Steph

Hello. I have some code that mainly references a worksheets 2 columns -
column D has the full path of a file, column A has a checkbox. The code
opens every file (one at a tine) that is listed in column D with a check in
A, updates links, prints the sheets listed in columns E through BB, and then
finally closes the file. It then loops through all files listed.

My issue is this - if I come across a file that has bad links, I get the
popup message indicating so. When I choose do not update links, the code
errors out. What I would like to happen is that the file is still opened,
links do not get updated if there are bad links, the file is left open and
the loop continues. So in the end, the only files that are still open will
be by default files with bad links. Is this possible? Thanks!! My code is
below:

Sub PrintFiles()

Set rng = Range("D7:D" & Range("D65536").End(xlUp).Row)
For Each cell In rng
If Trim(cell.Value) <> "" Then
If Cells(cell.Row, 1).Value = True Then
WbOpen = cell.Value
Workbooks.Open (WbOpen), UpdateLinks:=1
Set bk = ActiveWorkbook

ThisWorkbook.Activate
Set rng1 = cell.Offset(0, 1).Resize(1,
50).SpecialCells(xlConstants)
For Each cell1 In rng1
If LCase(cell1.Value) = "all" Then
bk.PrintOut
Exit For
Else
If Trim(cell1.Value) <> "" Then
bk.Worksheets(cell1.Value).PrintOut
End If
End If
Next

WbOpen = ""
bk.Close SaveChanges:=True
Set bk = Nothing
End If
End If
Next

End Sub
 

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