A
Alex
Whenn I have the Sheet1 opened and open the Sheet2 from the Excel window all
links in the Sheet1 are updated.
But, when I'm using the code below to update the links in the Sheet1
openning the Sheet2 programmaticaly it's not working.
What can be wrong with this code? Why the values in the Sheet1 are not
updated?
Sub Update_Links()
On Error GoTo Update_Links_Err
Dim xlapp As Object
Dim xlbook As Object
Dim strFileName As String
Dim logFlag As Boolean
logFlag = False
strFileName = "Sheet2.xls"
Set xlapp = CreateObject("Excel.Application")
xlapp.DisplayAlerts = False
xlapp.AskToUpdateLinks = False
Set xlbook = xlapp.Workbooks.Open(strFileName, UpdateLinks:=1)
logFlag = True
xlapp.AskToUpdateLinks = True
xlapp.DisplayAlerts = True
xlbook.Close savechanges:=True
xlapp.Quit
Set xlbook = Nothing
Set xlapp = Nothing
Update_Links_exit:
Exit Sub
Update_Links_Err:
xlapp.DisplayAlerts = True
xlapp.AskToUpdateLinks = True
If logFlag Then
xlbook.Close savechanges:=False
xlapp.Quit
Set xlbook = Nothing
Set xlapp = Nothing
End If
MsgBox Err.Description
Resume Update_Links_exit
End Sub
links in the Sheet1 are updated.
But, when I'm using the code below to update the links in the Sheet1
openning the Sheet2 programmaticaly it's not working.
What can be wrong with this code? Why the values in the Sheet1 are not
updated?
Sub Update_Links()
On Error GoTo Update_Links_Err
Dim xlapp As Object
Dim xlbook As Object
Dim strFileName As String
Dim logFlag As Boolean
logFlag = False
strFileName = "Sheet2.xls"
Set xlapp = CreateObject("Excel.Application")
xlapp.DisplayAlerts = False
xlapp.AskToUpdateLinks = False
Set xlbook = xlapp.Workbooks.Open(strFileName, UpdateLinks:=1)
logFlag = True
xlapp.AskToUpdateLinks = True
xlapp.DisplayAlerts = True
xlbook.Close savechanges:=True
xlapp.Quit
Set xlbook = Nothing
Set xlapp = Nothing
Update_Links_exit:
Exit Sub
Update_Links_Err:
xlapp.DisplayAlerts = True
xlapp.AskToUpdateLinks = True
If logFlag Then
xlbook.Close savechanges:=False
xlapp.Quit
Set xlbook = Nothing
Set xlapp = Nothing
End If
MsgBox Err.Description
Resume Update_Links_exit
End Sub